go to  ForumEasy.com   
JavaPro
Home » Archive » Message


[Email To Friend][View in Live Context][prev topic « prev post | next post » next topic]
  Proof from traffic log
 
Subject: Proof from traffic log
Author: Linux
In response to: Step 2 Make the minimum change
Posted on: 09/10/2017 10:14:34 PM

Started GET "/" for 127.0.0.1 at 2017-09-10 15:12:14 -0700
Processing by ApplicationController#greet as HTML
  Rendering html template
  Rendered html template (0.0ms)
Completed 200 OK in 170ms (Views: 4.8ms)


 

> On 09/10/2017 10:10:14 PM Linux wrote:

Rails framework follows the MVC philosophy, but here the "Hello World" is the simplest one which can only the C (controller) component.

First tale a look at the default controller: "app/controllers/application_controller.rb"
class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
end


Change it to:
class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception

  def greet
    render html: "Hello, World!"
  end

end


Then, instruct the routing table "config/routes.rb" to use the modified controller:
Rails.application.routes.draw do
  # For details on the DSL available within this file, 
see http://guides.rubyonrails.org/routing.html

  root 'application#greet'

end


Here, the 'root' (/) request will be handled by "application" controller (ApplicationController) on "greet" action.





References:

 


 
Powered by ForumEasy © 2002-2022, All Rights Reserved. | Privacy Policy | Terms of Use
 
Get your own forum today. It's easy and free.