The first layer is routing and the second layer the controller, so when in View, is there a way to dump out the path or filenames and li开发者_Python百科ne numbers of route and controller before reaching view?
I wanted to do this because www.example.com/stories/12345
is showing a page, but stories_controller.rb doesn't have a def index
or def show
Update: I guess it might be as if the program has an error, in which case it will show an application trace and a rails trace.
Well actually there is no other alternative than using a index
or show
and it has to be defined inside the class StoriesController. But it does not mean that those methods are defined inside the file "stories_controller.rb".
There are a few options:
- they are defined in the ApplicationController from which it derives. Or there is another parent-class.
- for instance, when you use ActiveScaffold your controller contains a single line
active_scaffold
that adds all the standard CRUD actions (index, show, ...)
To see where a method is defined, you could type inside your script/console
session
StoriesController.new.method('index')
and it would return a set of classes/modules, as explained here.
For instance, in our ApplicationController we include a module that defines a method login_required
, and that looks like this:
>> ApplicationController.new.method(:login_required)
=> #<Method: ApplicationController(PilgrimBase::Base::Authenticated)#login_required>
Hope this helps.
I know this doesnt really answer your question, but ... you can see your routes by doing
rake routes
do you have show.html.erb in your app/views/stories/ ?
精彩评论