In application.rhtml, controller is recognised as a variable, but action isn''t. Anything I can do about this? NameError in Reports#index Showing /layouts/application.rhtml where line #23 raised: undefined local variable or method `action'' for #<ActionView::Base:0xb75fcec4> Extracted source (around line #23): 20: » 21: <a href="http://localhost/<%=controller.controller_name%>"><%=controller.controller_name%></a> 22: » 23: <a href="http://localhost/<%=controller.controller_name + "/" + action %>"><%=action%></a> 24: 25: </div> 26: <div> -- Robert Jones
On Aug 14, 2005, at 8:46 AM, Robert Jones wrote:> In application.rhtml, controller is recognised as a variable, but > action > isn''t. Anything I can do about this? > >Try: <%= controller.action_name %> -Scott
Robert Jones wrote:> In application.rhtml, controller is recognised as a variable, but action > isn''t. Anything I can do about this?Doh! @params[:action] does it! -- Robert Jones
on another note i wouldnt recommend writing links yourself. <%= link_to controller, controller.action_name %> will work when you decide to move your website to a different host. On 8/14/05, Scott Barron <scott-HDQKq3lYuGDk1uMJSBkQmQ@public.gmane.org> wrote:> > On Aug 14, 2005, at 8:46 AM, Robert Jones wrote: > > > In application.rhtml, controller is recognised as a variable, but > > action > > isn''t. Anything I can do about this? > > > > > > Try: > <%= controller.action_name %> > > -Scott > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Zachery Hostens <zacheryph-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Thanks - I''ll use that! Robert Zachery Hostens wrote:> on another note i wouldnt recommend writing links yourself. > > <%= link_to controller, controller.action_name %> > > will work when you decide to move your website to a different host. > > On 8/14/05, Scott Barron <scott-HDQKq3lYuGDk1uMJSBkQmQ@public.gmane.org> > wrote: >> >> On Aug 14, 2005, at 8:46 AM, Robert Jones wrote: >> >> > In application.rhtml, controller is recognised as a variable, but >> > action >> > isn''t. Anything I can do about this? >> > >> > >> >> Try: >> <%= controller.action_name %> >> >> -Scott >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > >-- Robert Jones