Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Emilie's Rails App Presentation

Rails Girls uOttawa
January 31, 2015
75

Emilie's Rails App Presentation

#RailsGirlsuO

Rails Girls uOttawa

January 31, 2015
Tweet

Transcript

  1. Before we start.. Why Rails? Why Ruby? Ruby on Rails

    is 100% Open Sourced (YAY!) Effective in creating web applications, it’s concise and readable. Rails is a great skill to learn - companies are looking for it NOW!
  2. 1. Creating the application So we’re all on the same

    page: c9.io Let’s get up and running! Anatomy of the cloud IDE -->
  3. 6 steps to start editing 1. Sign up for a

    free account at Cloud9 (c9.io) 2. Click on “Go to your Dashboard” 3. Select “Create New Workspace” 4. Create a workspace called “railsgirls” set it to “Private to the people I invite”, and select the icon for the Rails Tutorial (not the icon for Ruby on Rails) 5. Click “Create” 6. After Cloud9 has finished provisioning the workspace, select it and click “Start editing”
  4. Installing Rails The development environment includes all software we’ll need

    to get started except rails :) Let’s go ahead and install it $ gem install rails -v 4.2.0
  5. Hello World? All rails applications start the same way; by

    running rails new command. [ cd ~/workspace ] $ rails new hello_app
  6. Bundler? I like bundles! But why with Rails? It installs

    and includes all the gems needed by the app. After creating a new Rails application, the next step is to use Bundler to install and include the gems needed by the app.
  7. Gemfile with an explicit versions of each Ruby gem Source

    'https://rubygems.org' gem 'rails', '4.2.0' gem 'sass-rails', '5.0.1' gem 'uglifier', '2.5.3' gem 'coffee-rails', '4.1.0' gem 'jquery-rails', '4.0.3' gem 'turbolinks', '2.3.0' gem 'jbuilder', '2.2.3' gem 'sdoc', '0.4.0', group: :doc group :development, :test do gem 'sqlite3', '1.3.9' gem 'byebug', '3.4.0' gem 'web-console', '2.0.0.beta3' gem 'spring', '1.1.3' end
  8. Let’s install these gems! $ cd hello_app/ $ bundle install

    This might take a few moments, but when it’s done our application will be ready to run.
  9. Stop, server time! You’re done! ...Seriously, you just created your

    first Ruby on Rails application. Now where is it?
  10. Rails server on the cloud IDE $ cd ~/workspace/hello_app/ $

    rails server -b $IP -p $PORT To shutdown your server: Ctrl-C Go to Share and click on the Application address to open it.
  11. Hello, World! Let’s add a controller action: render the string

    “Hello World!” which will replace the current landing page.
  12. Version control with Git First time system set up: First-Time

    repository setup: $ git init $ git add -A $git status
  13. ...Now what? $ git commit -m “Initializing repository” 1. Sign

    into your favourite Git repository hosting site. (Github, Bitbucket, etc) 2. Copy your public key using cat command. $ cat ~/.ssh/id_rsa.pub 3. Add public key to repo (https://github.com/settings/ssh)
  14. Now for the fun stuff! Time to implement a user

    model, along with web interface to the model. Users will be created by a scaffold generator program.
  15. Scaffolding: Quicker, easier. Scaffolding relies heavily on generated code, magically

    created by the Rails generate scaffold command. It can be overwhelming to a beginner Rails developer; you can use it, but you probably won’t understand it.
  16. Time to head south! $ bundle exec rake db:migrate This

    updates the database with our new users information
  17. Time to run! Run the local web server in a

    separate tab $ rails server -b $IP -p $PORT
  18. Weaknesses of this User resource? • No data Validations •

    No authentication • No tests • No style of layout • No real understanding Keep in mind. Scaffolding is good for building, but not to be used if you want the full understanding!
  19. Let’s do another one! $ rails generate scaffold idea name:string

    description:text picture:string Don’t forget! $ bundle exec rake db:migrate $ rails server -b $IP -p $PORT Open Application! ...is it working? (remember, ctrl-c to quit)
  20. Design Let’s do something about the look of our app..

    HTML + Rails? is this a thing? Every heard of Twitter Bootstrap?
  21. Thank you! Emilie Cobbold @SudoBeHappy Recommended further reading (free online

    Ruby on Rails tutorial) https://www.railstutorial.org/book/