Eduardo Naveda
Eduardo Naveda

Reputation: 2081

Where is this render method defined?

I'm going along this guide trying to get started with Rails: http://guides.rubyonrails.org/getting_started.html, I'm at this point in the tutorial where we have the following controller:

class PostsController < ApplicationController
  def new
  end

  def create
      render text: params[:post].inspect
  end
end

Where are these render method and params hash defined? what does this hash contain? I'm trying to search for ApplicationController in the API but I only find ActionController, which supposedly ApplicationController inherits from, still I can't seem to find the method or hash in the documentation, what am I missing here? thanks in advance for any comment or help.

Upvotes: 1

Views: 163

Answers (2)

DiegoSalazar
DiegoSalazar

Reputation: 13521

The relevant gem you want to look for is actionpack. Using bundler you can easily find or open the directory where this gem is installed:

bundle show actionpack
bundle open actionpack

Once you've open the actionpack gem in an editor that lets you do a project search, or grepped the directory where actionpack is installed, search for def params and def render and it will show you the file and line where these methods are defined. render is in lib/abstract_controller/rendering.rb line 95, and params is in lib/action_controller/metal.rb line 141.

Read the source Luke.

Upvotes: 2

nikolayp
nikolayp

Reputation: 17919

http://api.rubyonrails.org/classes/ActionView/Helpers/RenderingHelper.html#method-i-render You can pres source code and see the code of the method.

Upvotes: 1

Related Questions