Forum: Ruby on Rails Rendering an ApplicationController's action

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Eugenol (Guest)
on 2006-04-14 21:38
(Received via mailing list)
Hi !

I've pasted Rails Recipe #31: Authentication code, but I wish to use
these methods in several controllers. Then I pasted them in
ApplicationController, using before_filter method in all the other
needed controllers. The problem is that Rails always tries to render a
missing template inside the current controller (
app/views/controllers/admin/article/signin_form.rhtml ) while I've
uploaded it in app/views/application/siginin_form.rhtml ).

Is there an issue ?

Thanks for your help.
Mark Reginald J. (Guest)
on 2006-04-15 03:44
(Received via mailing list)
Eugenol wrote:

> I've pasted Rails Recipe #31: Authentication code, but I wish to use
> these methods in several controllers. Then I pasted them in
> ApplicationController, using before_filter method in all the other
> needed controllers. The problem is that Rails always tries to render a
> missing template inside the current controller (
> app/views/controllers/admin/article/signin_form.rhtml ) while I've
> uploaded it in app/views/application/siginin_form.rhtml ).

You have to put the view in the shared folder and explictly call

    render 'shared/siginin_form'



Should rails be changed to automatically render views of shared
actions from the shared folder, so that an explict render of

    render "#{controller_name}/view"

is needed only if the view is controller-dependent?  Which
is the more common situation.  For me, it's mostly been
a common view, but what option follows the principle of
least surprise?

--
We develop, watch us RoR, in numbers too big to ignore.
This topic is locked and can not be replied to.