Create action from a button?

Beau
Fri, 05 Aug 2011 10:33:22 -0000

Hello all.

I''ve got a model that basically records whever a user has completed an
action. When it''s created it auto fills in the user_id via sessions
etc.

However I want to create links on the various actions, so users can
just click them, eg navigating possible actions with a button for
"complete!" and that will insert a value into the model for them.

<%= button_to "Complete!",user_actions_path,:action_id =>
action.id,  :method => :post %>

This posts the page correctly, however it complains that the action/
action_id is null (as i''m using validations in the model to stop this.
I''ve tried tweaking action_id to action and removing action.id etc.
But nothing works. Action id is a proper id too, but by the time rails
gets to it it''s null...

I have no idea how to fix this too?. Anyone got any clues?