Trying to link to edit from a different form.

Hey everyone,

I am currently writing a Bet program, which consists of 5 forms, a home form and a form for all of my tables. I am trying to use the button_to command to link from the home controller/index to another forms/edit action.

This is what I have so far, any help would be great:

<td><%= button_to 'Decrease Date', {:controller => :bets, :id => Bet.find_by_milestone_id(m.id), :action => :edit} %></td>

and I receive this error: Couldn't find Bet without an ID

Thanks, Hunter

Hunter Mcmillen wrote:

Hey everyone,

I am currently writing a Bet program, which consists of 5 forms, a home form and a form for all of my tables. I am trying to use the button_to command to link from the home controller/index to another forms/edit action.

This is what I have so far, any help would be great:

<td><%= button_to 'Decrease Date', {:controller => :bets, :id => Bet.find_by_milestone_id(m.id), :action => :edit} %></td>

and I receive this error: Couldn't find Bet without an ID

Thanks, Hunter

So I fixed this issue, now what is happening is the that button_to function loads the url in my browser then say Unknown Action.

But if I manually enter that same url, it goes to the page I want.

Here's the button_to: <td><%= if !Bet.find_by_milestone_id(m.id).nil?   button_to 'Decrease Date', {:controller => :bets, :action => :edit, :id => Bet.find_by_milestone_id(m.id)}         end %></td> <td><%= if !Bet.find_by_milestone_id(m.id).nil?       button_to 'Increase Date', {:controller => :bets, :action => :edit, :id => Bet.find_by_milestone_id(m.id)}   end %></td>

And here's there error: Unknown action

No action responded to 38. Actions: create, destroy, edit, index, new, show, and update

Any help would be great. Thanks, Hunter