Skip to content

Instantly share code, notes, and snippets.

@wh1tney
Created August 28, 2014 19:12
Show Gist options
  • Save wh1tney/82e5fa335342ab28129d to your computer and use it in GitHub Desktop.
Save wh1tney/82e5fa335342ab28129d to your computer and use it in GitHub Desktop.
Rails Workflow - Getting Started

Rails Workflow

A few simple steps when starting a new Rails project

  • rails new <app_name>

  • Update Gemfile to include gems for testing

    • e.g. RSpec, FactoryGirl, Capybara
     group :development, :test do
     	gem "rspec-rails"	
     end
     
     group :test do
     	gem "capybara"
     	gem "launchy"
     	gem "factory_girl_rails"
     	gem "database_cleaner"
     end
    
  • Generate RSpec stuff

    • bundle exec rails generate rspec:install
  • Generate controller

    • rails generate controller <controller_name>
  • Generate model

    • rails generate model <model_name>
  • Edit controller test (or don't) inside spec/controllers/ directory

    • vim spec/controllers/*_controller_spec.rb
  • Update routes in config/routes.rb

    • get '/jiggy' => 'willenium#dance'
  • Add controller actions (methods) model that satisfy controller test

     def dance
     	@jig = Jig.create(jig_params)
     end
     
     private
     
     def jig_params
     	params.require(:jig).permit(:style, :level)
     end
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment