Is there an easy way to have a piece of code or even an entire layout that not only loads for a given controller, but only a given action on that controller? Specifically, I''m trying to load a small Google Map using their API, and I''ve written it to automatically geocode the address based on an address value passed from the controller. I have a controller called "events" that lists a bunch of upcoming events, and when you select an event, a details page for that event is invoked via the "details" action. The API only gets passed the address for geocoding when "details" is loaded, but in its current state, it also wants the address everywhere in the events controller, and since it''s "nil" Rails gives me an error. I want to be able to only load the map from the Javascript code when one action is invoked, not when the whole "events" view is loaded. Is there an easy way to do this with layouts? (Sorry for the roundabout question, as I''m something of a newb when it comes to programming and a total newb when it comes to RoR). Thanks! - Coleman -- 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 -~----------~----~----~----~------~----~------~--~---
If I''m understanding you right, you should be able to just do: render :layout => ''events'' Put that in the controller method for the action you want the layout loaded for. Any other actions will still use the default layout for that controller - Paul On Jan 30, 3:53 pm, Coleman Mccormick <rails-mailing-l...@andreas- s.net> wrote:> Is there an easy way to have a piece of code or even an entire layout > that not only loads for a given controller, but only a given action on > that controller? Specifically, I''m trying to load a small Google Map > using their API, and I''ve written it to automatically geocode the > address based on an address value passed from the controller. > > I have a controller called "events" that lists a bunch of upcoming > events, and when you select an event, a details page for that event is > invoked via the "details" action. The API only gets passed the address > for geocoding when "details" is loaded, but in its current state, it > also wants the address everywhere in the events controller, and since > it''s "nil" Rails gives me an error. I want to be able to only load the > map from the Javascript code when one action is invoked, not when the > whole "events" view is loaded. Is there an easy way to do this with > layouts? > > (Sorry for the roundabout question, as I''m something of a newb when it > comes to programming and a total newb when it comes to RoR). > > Thanks! > - Coleman > > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
crayz wrote:> If I''m understanding you right, you should be able to just do: > render :layout => ''events'' > > Put that in the controller method for the action you want the layout > loaded for. Any other actions will still use the default layout for > that controller > > - Paul > > On Jan 30, 3:53 pm, Coleman Mccormick <rails-mailing-l...@andreas-You''re exactly right. I was just about to reply that I figured it out. Pretty simple solution. Thanks a lot! -- 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 -~----------~----~----~----~------~----~------~--~---