0

In rails if you were to render static pages you would use a class like below:

class StaticPagesController < ApplicationController
  def home
  end
  def about
  end
end

how does the ApplicationController process these functions so as to produce a get request? And what is the difference between the function processing and when the functions are named after HTTP verbs and they route accordingly?

Zach Smith
  • 8,458
  • 13
  • 59
  • 133
  • May be you should look into this http://api.rubyonrails.org/classes/ActionController/Base.html – Pavan Jun 30 '14 at 08:42
  • ok, so i guess my question is: how does inheriting from a class give these functions functionality? Because I'm struggling to visualise how these functions actually do anything – Zach Smith Jun 30 '14 at 09:05
  • Actions, by default, render a template in the app/views directory corresponding to the name of the controller and action after executing code in the action. For example, the index action of the PostsController would render the template app/views/posts/index.html.erb by default after populating the @posts instance variable.See this line in the line – Pavan Jun 30 '14 at 09:07
  • what is the methodology behind that? i.e. the logic of the ApplicationController. Although, since ApplicationController inherits from ActionController::base, what is the logic of the ActionController::base class that does this? i.e is it using method_missing? something else? where can I find out about this? – Zach Smith Jun 30 '14 at 09:49

0 Answers0