Good evening all. I have two different places in my app that need to call the same controller/action and react differently in terms of output. In other words, in one case I want to use some rjs to update a page in a certain way and in another case - I''d like to to do something entirely different to a different/distinct page but use the same controller/action. Say controller is foo and action is ''unsubscribe''... class Foo << ApplicationController def unsubscribe foo = SomeModel.find(params[:id]) if foo SomeModel.delete_all(:condtions....) end # in one case i want to update the calling page (x) with some indication # in another, the page has a completely different dom and i need to do something else render :update do |page| page.do_something end end end Is the answer to just create two actions here? -- 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 -~----------~----~----~----~------~----~------~--~---
Cory Wilkerson wrote:> Is the answer to just create two actions here?It''s not the only answer but I prefer it over the alternative which is to pass a hidden field into the controller indicating which branch it is to follow. Of course splitting your code into more methods leads to more maintainable, easier to understand, more cohesional, prettier, and easier test case coverage goodness but who cares about those things anyways.. :) If your action names are starting to match in the controller space then maybe it''s time you split into another controller.. -- 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 -~----------~----~----~----~------~----~------~--~---
@Cory, take a look at the RJS proxies for the DOM. Things like page.select(...).any should help for what you''re trying to achieve. On Mar 2, 7:05 pm, Cory Wilkerson <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Good evening all. > > I have two different places in my app that need to call the same > controller/action and react differently in terms of output. In other > words, in one case I want to use some rjs to update a page in a certain > way and in another case - I''d like to to do something entirely different > to a different/distinct page but use the same controller/action. > > Say controller is foo and action is ''unsubscribe''... > > class Foo << ApplicationController > def unsubscribe > foo = SomeModel.find(params[:id]) > if foo > SomeModel.delete_all(:condtions....) > end > > # in one case i want to update the calling page (x) with some > indication > # in another, the page has a completely different dom and i need to > do something else > render :update do |page| > page.do_something > end > end > end > > Is the answer to just create two actions here? > -- > 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 -~----------~----~----~----~------~----~------~--~---