I want a page that lets users add members to a group from a longer list, or remove members from that group. I can use Ajax to transfer a name from the long list to the group, or drop an existing name from the group. But. If I add a person to the group, and try to remove without refresh, it doesn''t work. My link is formed by <%= link_to_remote ''add'', :url => { :action => "remove_member", :id => person.id, :group_id => group.id"} %> For a member who''s in the group when I reach the page, that generates a call to /controller/remove_member/person.id?group_id=group.id as it should. But if I add a member ''foo'' to the group and then try to remove the same person, the call is controller/remove_member/foo.id. I''ve been able to hack around it by setting :id => "#{person.id}.{group.id}" in the link_to_remote, but there''s got to be a better way. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Zack Chandler
2006-Aug-08 01:02 UTC
[Rails] problem inserting parameters in link_to_remote
What you really want to do is read and apply the ideas in this post: http://www.loudthinking.com/arc/000593.html (straight from the source). Then read: http://www.loudthinking.com/lt-files/worldofresources.pdf. Your exact scenario is shown on page 21. RESTful rocks! Hope this helps, Zack On 8/7/06, B Gates <bmathg@yahoo.com> wrote:> I want a page that lets users add members to a group > from a longer list, or remove members from that group. > I can use Ajax to transfer a name from the long list > to the group, or drop an existing name from the group. > > But. > > If I add a person to the group, and try to remove > without refresh, it doesn''t work. My link is formed > by <%= link_to_remote ''add'', :url => { :action => > "remove_member", :id => person.id, :group_id => > group.id"} %> For a member who''s in the group when I > reach the page, that generates a call to > /controller/remove_member/person.id?group_id=group.id > as it should. But if I add a member ''foo'' to the > group and then try to remove the same person, the call > is controller/remove_member/foo.id. > > I''ve been able to hack around it by setting :id => > "#{person.id}.{group.id}" in the link_to_remote, but > there''s got to be a better way. > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Thanks, but that doesn''t address the problem that the parameter isn''t being passed to the action in the first place. Does it? I mean, I can add a member to a group just fine; the problem is that after I''ve added a member, and used a remote call to update the members list, it''s not possible to do a remote call to remove that same member because for some reason the inserted link_to_remote for the new member just drops the group_id parameter. How does REST fix that? And speaking of dropping parameters, does anyone know how to respond to a thread on this list from a web-based mail account? ... What you really want to do is read and apply the ideas in this post: http://www.loudthinking.com/arc/000593.html (straight from the source). Then read: http://www.loudthinking.com/lt-files/worldofresources.pdf. Your exact scenario is shown on page 21. RESTful rocks! __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Zack Chandler
2006-Aug-08 14:02 UTC
[Rails] Re:problem inserting parameters in link_to_remote
Post you controller and partial code and maybe someone on the list can better help. You should be able to simply reply to this email from your web-based mail account. Zack On 8/8/06, B Gates <bmathg@yahoo.com> wrote:> Thanks, but that doesn''t address the problem that the > parameter isn''t being passed to the action in the > first place. Does it? I mean, I can add a member to > a group just fine; the problem is that after I''ve > added a member, and used a remote call to update the > members list, it''s not possible to do a remote call to > remove that same member because for some reason the > inserted link_to_remote for the new member just drops > the group_id parameter. How does REST fix that? > > And speaking of dropping parameters, does anyone know > how to respond to a thread on this list from a > web-based mail account? > ... > What you really want to do is read and apply the ideas > in this post: > http://www.loudthinking.com/arc/000593.html (straight > from the > source). Then read: > http://www.loudthinking.com/lt-files/worldofresources.pdf. > Your exact > scenario is shown on page 21. RESTful rocks! > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >