Hi there. I''d like to add a custom action, let''s call it "add_association", that will add a relation between two models that are linked using has_and_belongs_to_many. I''ve tried the following, ... member.resources :model_b, :member => { :associate => :post } ... which creates a route like http://localhost:3000/model_a/9/model_b/associate which seems to be ok. But when I try to request that url, I receive the following error: Unknown action No action responded to show That''s weird. How could that custom action be linked with show? Thanks... David -- 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 -~----------~----~----~----~------~----~------~--~---
With that route, you need to POST to this URI: http://localhost:3000/model_a/9/model_b/1;associate I assume you tried calling http://localhost:3000/model_a/9/model_b/associatewith the GET method so Rails is looking for the "model_b" with a id of "associate" since GET maps to Controller#show. ed On 2/6/07, David Scheffel <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Hi there. > > I''d like to add a custom action, let''s call it "add_association", that > will add a relation between two models that are linked using > has_and_belongs_to_many. I''ve tried the following, ... > > member.resources :model_b, :member => { :associate => :post } > > ... which creates a route like > http://localhost:3000/model_a/9/model_b/associate which seems to be ok. > But when I try to request that url, I receive the following error: > > Unknown action > No action responded to show > > That''s weird. How could that custom action be linked with show? > > Thanks... > David > > -- > 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 -~----------~----~----~----~------~----~------~--~---
Thanks! That makes sense. But how to write an action that could be used to search for an entry in model_b and would then call "associate" with post to link the two models together? Would I need to write a separate controller for the porpose of searching? Thanks... David -- 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 -~----------~----~----~----~------~----~------~--~---