rails serve code example

Example 1: how to generate a controller in rails

$ rails generate controller Greetings hello
	 
     # Below are the files this generator creates
     # hello would create a view file
     # to create the controller without creating the view file enter:
     # rails generate controller Greetings
     
     create  app/controllers/greetings_controller.rb
      route  get 'greetings/hello'
     invoke  erb
     create    app/views/greetings
     create    app/views/greetings/hello.html.erb
     invoke  test_unit
     create    test/controllers/greetings_controller_test.rb
     invoke  helper
     create    app/helpers/greetings_helper.rb
     invoke    test_unit
     invoke  assets
     invoke    scss
     create      app/assets/stylesheets/greetings.scss

Example 2: how to create new rails app

#first make sure you have rails installed, then...
rails new your_new_rails_app_name

Tags:

Ruby Example