Tags

C:\railsproject\demo_app>rails generate controller Say hello goodbye
create app/controllers/say_controller.rb
route get 'say/goodbye'
route get 'say/hello'
invoke erb
create app/views/say
create app/views/say/hello.html.erb
create app/views/say/goodbye.html.erb
invoke test_unit
create test/functional/say_controller_test.rb
invoke helper
create app/helpers/say_helper.rb
invoke test_unit
create test/unit/helpers/say_helper_test.rb
...
...
C:\railsproject\demo_app>rails generate scaffold Micropost content:string user_id:integer
      invoke  active_record
      create    db/migrate/20130131110511_create_microposts.rb
      create    app/models/micropost.rb
      invoke    test_unit
      create      test/unit/micropost_test.rb
      create      test/fixtures/microposts.yml
      invoke  resource_route
       route    resources :microposts

C:\railsproject\demo_app>rake routes
    microposts GET    /microposts(.:format)          microposts#index
               POST   /microposts(.:format)          microposts#create
 new_micropost GET    /microposts/new(.:format)      microposts#new
edit_micropost GET    /microposts/:id/edit(.:format) microposts#edit
     micropost GET    /microposts/:id(.:format)      microposts#show
               PUT    /microposts/:id(.:format)      microposts#update
               DELETE /microposts/:id(.:format)      microposts#destroy
         users GET    /users(.:format)               users#index
               POST   /users(.:format)               users#create
      new_user GET    /users/new(.:format)           users#new
     edit_user GET    /users/:id/edit(.:format)      users#edit
          user GET    /users/:id(.:format)           users#show
               PUT    /users/:id(.:format)           users#update
               DELETE /users/:id(.:format)           users#destroy
...
...

# List all gems installed in ruby
C:\railsproject\demo_app>gem list --local rails
*** LOCAL GEMS ***
rails (3.2.11)

# List all gems installed in current app
C:\railsproject\demo_app>bundle list
*** LOCAL GEMS ***
jquery-rails (3.2.11)
json (3.2.11)

# To install a specific rails version
C:\railsproject\demo_app>gem install rails --version 3.0.3

# Add column 'lastname' to existing table (Student)
# file naming can be used as Camelcase or undescore, see below
C:\railsproject\demo_app>rails g migration add_lastname_to_students lastname:string ### or 
C:\railsproject\demo_app>rails g migration AddLastnameToStudents lastname:string

# Run the migration
bundle exec rake db:migrate

# SHORTCUT WAY
C:\railsproject\demo_app>rails g # for generate
C:\railsproject\demo_app>rails s # for server
C:\railsproject\demo_app>rails c # for console

Advertisements