I have a navigation bar which buttons should activate themselves on click but "params[:thistheme]" is always nil in my partial. Why? my view ----------------------------------------------------------------------- <%= render :partial => ''shared/themeMnuBtn_1'' %> ----------------------------------------------------------------------- _themeMnuBtn_1 ----------------------------------------------------------------------- <% if params[:thistheme] == 1 %> <li class="themeMnu1Active"><%= link_to_remote "<b>HOTEL</b>", :url => { :action => ''index'', :thistheme => 1 }, :update => ''resultsTable'', :with => "''thiscity=''+escape($F(''city_lookup''))" %></li> <% else %> <li><%= link_to_remote "<b>HOTEL</b>", :url => { :action => ''index'', :thistheme => 1 }, :update => ''resultsTable'', :with => "''thiscity=''+escape($F(''city_lookup''))" %></li> <% end %> ----------------------------------------------------------------------- -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
looks better: <% if params[:thistheme] == 1 %> <li class="themeMnu1Active"><%= link_to_remote "<b>HOTEL</b>",:url => { :action => ''index'', :thistheme => 1 }, :update => ''resultsTable'', :with => "''thiscity=''+escape($F(''city_lookup''))" %> </li> <% else %> <li><%= link_to_remote "<b>HOTEL</b>", :url => { :action => ''index'', :thistheme => 1 }, :update => ''resultsTable'', :with => "''thiscity=''+escape($F(''city_lookup''))" %> </li> <% end %> -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Why are you using params? You should be either setting a member variable or using the flash if this is a one-time good thing. From the looks of it, you want a member variable. aka <% if @this_theme == 1 %> Jason On 10/11/07, Zoran Kikic <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > I have a navigation bar which buttons should activate themselves on > click but > "params[:thistheme]" is always nil in my partial. Why? > > my view > ----------------------------------------------------------------------- > <%= render :partial => ''shared/themeMnuBtn_1'' %> > ----------------------------------------------------------------------- > > _themeMnuBtn_1 > ----------------------------------------------------------------------- > <% if params[:thistheme] == 1 %> > <li class="themeMnu1Active"><%= link_to_remote "<b>HOTEL</b>", :url => > { :action => ''index'', :thistheme => 1 }, > :update > => ''resultsTable'', > :with > => "''thiscity=''+escape($F(''city_lookup''))" %></li> > <% else %> > <li><%= link_to_remote "<b>HOTEL</b>", :url => { :action => > ''index'', :thistheme => 1 }, > :update > => ''resultsTable'', > :with > => "''thiscity=''+escape($F(''city_lookup''))" %></li> > <% end %> > ----------------------------------------------------------------------- > -- > 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
but how can I set the variable in link_to_remote ? -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Are you expecting PHP-like behavior here? What exactly are you trying to do? Jason On 10/11/07, Zoran Kikic <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > but how can I set the variable in link_to_remote ? > -- > 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Well, link_to_remote sets ":thistheme => 1" (I can access to it in my controller). So I know button 1 (=thistheme 1) was clicked. In this case my button should get the style "themeMnu1Active". That''s all. I thought the best way would be to use already available informations: params[:thistheme]. but it''s nil in my partial. And yes, unfortunately I am influenced by php.. -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Well, as it stands, you need to stop what you''re doing and read up on how Rails works. If you are up to buying a book, I highly recommend Agile Development with Rails v2: http://www.pragprog.com/title/rails/ Unfortunately, free tutorials on the net aren''t easy to find that help out, but here''s the Rails wiki page: http://wiki.rubyonrails.org/rails/pages/GettingStartedWithRails Also, just in case you don''t know about the MVC pattern (what Rails is built upon), there''s information here: http://en.wikipedia.org/wiki/Model-view-controller In short, link_to_remote sends an Ajax call to a controller (#index, in this case). params[] is available in that controller for you to use. I don''t think that''s what you want. Stick to non-Ajax calls (#link_to), it''s good practice anyways. Also, here''s the Rails API docs: http://api.rubyonrails.org Let us know if you need any specific help! Jason On 10/11/07, Zoran Kikic <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Well, link_to_remote sets ":thistheme => 1" (I can access to it in my > controller). So I know button 1 (=thistheme 1) was clicked. In this case > my button should get the style "themeMnu1Active". That''s all. I thought > the best way would be to use already available informations: > params[:thistheme]. but it''s nil in my partial. And yes, unfortunately I > am influenced by php.. > -- > 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---