AdvanceInBeginning
AdvanceInBeginning

Reputation: 99

Debug (get to know) what has controller

I know from a tutorial, that <%= controller.controller_name %> prints out the controllers name.

Now i figure out, how to dumnp all the hidden information in the controller.

i tried with

<%= debug(controller.instance_methods.to_yaml) if Rails.env.development?  %>
<%= debug(controller.to_yaml) if Rails.env.development?  %>

or with an each, but nothing works. Please teach me (without using a gem) how to see all the nice informations.

Upvotes: 0

Views: 144

Answers (2)

Santhosh
Santhosh

Reputation: 29094

Use Object#methods to get all the methods in an object

controller.methods

Module#intance_methods is a class method, So you should call it using Class.

controller.class.instance_methods

You can pass false to not include inherited methods

controller.class.instance_methods(false)

Upvotes: 1

realwol
realwol

Reputation: 1

Though I not really understand your question, is this what you want?

<%= debug(params) if Rails.env.development? %>

Upvotes: 0

Related Questions