http://stackoverflow.com/questions/7156955/whats-the-difference-between-equal-eql-and
Db:rest
Josh found:
http://stackoverflow.com/questions/10301794/difference-between-rake-dbmigrate-dbreset-and-dbschemaloadhttp://rake.rubyforge.org/
Rails comes equipped with three environments: test, development, and production. The default environment for the Rails console is development:
If you ever need to run a console in a different environment (to debug a test, for example), you can pass the environment as a parameter to the console script:
$ rails console test
As with the console, development is the default environment for the local Rails server, but you can also run it in a different environment:
$ rails server --environment production
If you view your app running in production, it won’t work without a production database, which we can create by running rake db:migrate in production:
$ bundle exec rake db:migrate RAILS_ENV=production
REST!!!!!
POST, GET, PATCH, and DELETE
When following REST principles, resources are typically referenced using the resource name and a unique identifier.
show when Rails’ REST features are activated, GET requests are automatically handled by the show action.
______________________________________________________________________________________________________________________________________________________________________http://stackoverflow.com/questions/10301794/difference-between-rake-dbmigrate-dbreset-and-dbschemaloadhttp://rake.rubyforge.org/
Rails comes equipped with three environments: test, development, and production. The default environment for the Rails console is development:
If you ever need to run a console in a different environment (to debug a test, for example), you can pass the environment as a parameter to the console script:
$ rails console test
As with the console, development is the default environment for the local Rails server, but you can also run it in a different environment:
$ rails server --environment production
If you view your app running in production, it won’t work without a production database, which we can create by running rake db:migrate in production:
$ bundle exec rake db:migrate RAILS_ENV=production
REST!!!!!
POST, GET, PATCH, and DELETE
When following REST principles, resources are typically referenced using the resource name and a unique identifier.
show when Rails’ REST features are activated, GET requests are automatically handled by the show action.
HTTP request | URL | Action | Named route | Purpose |
GET | /users | index | users_path | page to list all users |
GET | /users/1 | show | user_path(user) | page to show user |
GET | /users/new | new | new_user_path | page to make a new user (signup) |
POST | /users | create | users_path | create a new user |
GET | /users/1/edit | edit | edit_user_path(user) | page to edit user with id1 |
PATCH | /users/1 | update | user_path(user) | update user |
DELETE | /users/1 | destroy | user_path(user) | delete user |
Here we’ve used params to retrieve the user id. When we make the appropriate request to the Users controller, params[:id] will be the user id 1, so the effect is the same as the find method
@user = User.find(params[:id])
User.find(1)
Technically, params[:id] is the string "1", but find is smart enough to convert this to an integer.
Factory Girl is a DSL for defining Active Record objects.
No comments:
Post a Comment