Hi there. I have a forum controller, where the admin can change the status of a treat, in /forums/status/ID?status=STATUS in the controller, i have defined it as def status @treatId = params[:id] @status = params[:status] end What code should i use to update the status in the row corresponding to the @treatId ? Thanks :) Emil -- 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 -~----------~----~----~----~------~----~------~--~---
Hi Emil,
first of all it seems to me like you''re using the GET method for
updating the status. I think you better stick to the POST method for
your form. The GET method is good for querying your database through
request parameters. The POST method is better for creating or editing a
post.
So your URL should become with the GET method something like
/forums/status/4. In your controller you can put:
def status
@thread = Thread.find(params[:thread][:id])
@thread.update_attributes = params[:thread]
if @thread.save
...
end
end
If in your form have update one attribute like the status
(params[:thread][:status]) then the update_attributes will only update
this attribute.
I''m just a newbie to Ruby and these are my suggestions...
Best regards,
Mark
--
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
-~----------~----~----~----~------~----~------~--~---