If you don't have a defined action, Rails looks for a corresponding template with the same name as the controller/action
If it finds one, it just renders that template. If it doesn't find one, it just raises a missing template error.
It's been like this since the dawn of Rails.
On Sep 8, 2014, at 9:50 AM, Ronald Fischer <lists@ruby-forum.com> wrote:
> One of my routes looks like this:
>
> admin_pages_home GET /admin_pages/home(.:format)
> admin_pages#home
>
> In one of my views, I have a link to admin_pages_home_path, and clicking
> on this link indeed works and renders admin_pages/home.html.erb, as we
> can see from the logfile:
>
> Started GET "/admin_pages/home" for 127.0.0.1 at 2014-09-08 15:32:41
> +0200
> Processing by AdminPagesController#home as HTML
> Rendered admin_pages/home.html.erb within layouts/application (7.6ms)
>
> Now, the weird thing here is that I had forgotten to define a home()
> function in AdminPagesController (and I also didn't put one in
> ApplicationController). Actually, the only other home method I have is
> in a completely unrelated controller.
>
> I wonder how it can be, that clicking on the admin_pages_home_path link,
> didn't raise an exception.
>
> Ronald
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8a99e998a76916b3955e2782e58ad2d0%40ruby-forum.com.
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CCDF4EFD-61AB-4E8A-9C85-FF9AC047C456%40datatravels.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment