Hi, this is probably a really simple question, but I want to create a link that does this when you click it: It enters the ID of the current session, and the ID of the user profile page into a database table called "friends". The button basically adds friends to the current user. I''m guessing that the link should look something like: <%= link_to ''Add as a friend'', :controller => ''users'', :action => ''addfriend'', :id => user.id %> I''m obviously new to this and can''t figure out what the action ''addfriend'' should look like in the controller so the two id''s can be entered into the table. Nothing works, and I feel like I''m just stabbing in the dark. Any ideas? Thanks! -- 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 -~----------~----~----~----~------~----~------~--~---
Bill Walton
2006-Nov-11 02:17 UTC
Re: Probably easy -- data from controller into a database
Hi Dave, Dave A. wrote:> Nothing works, and I feel like I''m just > stabbing in the dark.What have you tried? This list can be very helpful. More so, the more you let us know. Looking forward... Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Bill Walton
2006-Nov-11 02:32 UTC
Re: Probably easy -- data from controller into a database
Dave A. wrote:> :id => user.id %>hint: what''s user? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Bill Walton wrote:> Dave A. wrote: >> :id => user.id %> > > hint: what''s user?Oops, user is a reference to the users table, the id column. Sorry I didn''t give more information, I assumed creating a controller action that enters data into a database was really obvious and I was just missing something. All I''ve tried are variations on controller code generated by scaffold, so it starts something like: def addfriend if request.post? @friend.save end Beyond that, I don''t know. Also, do I have to put this action in the friends controller, since I''m inserting data into the friends database, or can I put wherever I want (like the Users 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 -~----------~----~----~----~------~----~------~--~---