tng-rails-code-snippets.md#

A#

Ways of debugging params coming into controller#

Rails.logger.debug params.inspect

<%= params.inspect %>
<%= params[:title] %>

> raise params.inspect

You can use for models, controllers, etc.

> puts YAML::dump(params)

def create
  render plain: params[:article].inspect
end

More ways to see details of controllers#

ApplicationController object is instantiated when there is a presence of HTTP request from a client. For example, if you have an action test on application_controller.rb with routes.rb entry get '/test' => 'application#test':

class ApplicationController < ActionController::Base

  def test
    puts "Instance: #{self}"
    puts "Instance Methods: #{self.methods}"
  end

end

You can start your local server and visit http://localhost:3000/test and check your server logs to inspect the ApplicationController object and it's methods.

For detailed inspection, I would recommend adding gem 'pry' to your Gemfile and bundling it, then using binding.pry on the ApplicationController#test action, which allows you to further inspect the object on your server on runtime.

ApplicationController in Rails is unique to your application, but it inherits from another class called ActionController:: Base. I'm guessing you want to know what methods this particular class exposes.

Summarising http://api.rubyonrails.org/classes/ActionController/Base.html :

The ActionController::Base class takes care of all the web requests, and does the job of passing requests to and from the Rails routes. It makes available methods like :

request (the whole object of the web request made which is used to interpret which controller action to invoke) params (makes the parameters sent to the server available to your action), session (maintains your session variables), etc.

Chrome/Firefox extension for Rails development#