I have a simple div in my layout that I would like to change depending on the action. For instance in the account/signup I would like it to use <div id="register"> but in account/login I would like it to use <div id="login"> I''m trying to find the right if statement to use here.. I thought that maybe: if :action => login would work but it doesn''t.. thanks.. -- Posted via http://www.ruby-forum.com/.
Try controller.action_name or controller.controller_name -----Original Message----- From: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Vince W. Sent: Tuesday, June 13, 2006 11:11 AM To: rails@lists.rubyonrails.org Subject: [Rails] If... what? I have a simple div in my layout that I would like to change depending on the action. For instance in the account/signup I would like it to use <div id="register"> but in account/login I would like it to use <div id="login"> I''m trying to find the right if statement to use here.. I thought that maybe: if :action => login would work but it doesn''t.. thanks.. -- Posted via http://www.ruby-forum.com/. _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails
Vince W. wrote:> I have a simple div in my layout that I would like to change depending > on the action. For instance in the account/signup I would like it to > use <div id="register"> but in account/login I would like it to use <div > id="login"> > > I''m trying to find the right if statement to use here.. I thought that > maybe: > > if :action => login would work but it doesn''t.. > > thanks..<div id="<%= params[:action] %>"> or, from a helper: def sidebar_id(action) action = action.to_s case action when ''signup'' : ''register'' when ''foo'' : ''bar'' else : action end end # View <div id="<%= sidebar_id(params[:action]) %>"> -- Posted via http://www.ruby-forum.com/.