Introduction/Basics Flashcards

1
Q

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.

A

rails new [name]

rails new [name] –database=postgresql –skip-test –skip-bundle

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is another name for a function in a Rails application

A

actions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you check that all the gems are installed?

A

bundle install

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Looking at the request/response cycle, what are the three parts to a Rails application

A

Route, controller, view

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you create a controller?

A

rails generate controller Pages

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you create a route?

A

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’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the RSpec generator command to install rspec for your rails app?

A

bundle exec rails generate rspec:install

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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?

A

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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Before you can start working on a rails app, there is one last configuration you need to add, what this?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly