Introduction/Basics Flashcards
How do you create a new Rails app/ start a project? How would you make new rails app, setting postgresql as the database, skip configuring for the default testing pool and skipping bundle install.
rails new [name]
rails new [name] –database=postgresql –skip-test –skip-bundle
What is another name for a function in a Rails application
actions
How do you check that all the gems are installed?
bundle install
Looking at the request/response cycle, what are the three parts to a Rails application
Route, controller, view
How do you create a controller?
rails generate controller Pages
How do you create a route?
You go into your rails app folder, then into the config folder and then into routes.rb file. There you write: get ‘welcome’ => ‘pages#home’
What is the RSpec generator command to install rspec for your rails app?
bundle exec rails generate rspec:install
The shoulda-matchers gem is very hand for testing common rails functionality, like validations and associations with less code, before you start using this gem, you need to configure how and where do you add a certain block of code?
In the file: spec/rails_helper.rb, add the following:
Shoulda::Matchers.configure do |config| config.integrate do |with| with.test_framework :rspec with.library :rails end end
Before you can start working on a rails app, there is one last configuration you need to add, what this?
You need to add a configuration to the config/application.rb file to disable some generators, from scaffolding too many files.
In the file:
config.generators do |generate|
generate.helper false
generate.assets false
generate.view_specs false
generate.helper_specs false
generate.routing_specs false
generate.controller_specs false
end