restful multi button form

Hey,

I have a controller messages which for the index action lists messages. I want buttons to be able to serve actions "mark_read" and "delete".

how do i create my form to be able to submit the buttons without it redirecting to the create action for my controller ?

chubbs

hey i asked this a while back and am still struggling to work out a nice way to do this,

can anyone help?

If I understood you correctly, "by clicking mark read", it should update a mark_read boolean field to be true instead of false, in that case you can set your form to go to PUT process (update action method), and for delete you can still go to DELETE process (destroy action method) in your controller. But my solution here is involving two forms for each of your record inside your object listing iteration. cos I don't see the reason why combine them in one.

ex. form_tag book_path(book), :method => :put do   hidden_field_tag :mark_read, :value => "1" end

and form_tag book_path(book), :method => :delete do   hidden_field_tag :id, :value => book.id end

ye i kinda need it to be in one form cos i have check boxes for each of the messages

i made it work like this:

<% form_tag :action => "inbox_action" do %>    .....    <%= check_box_tag("select", message.id, false) %> <%= submit_tag("Delete", :name => "submit" )%> <%= submit_tag("Mark Read", :name => "submit")%> <% end %>

def inbox_action   case params[:submit]   when 'Delete'     destroy #destroy action   when 'Mark Read'     if(params[:select])       selected_pms = @current_user.user_privmsgs.find(params[:select])       for pm in selected_pms         pm.is_unread = false         pm.save       end     end   end   redirect_to privmsgs_url end

bit confused how this works with using rest, so i dont it that way. dunno if its a good way to do it tho.

chubbs