# Trying to link to edit from a different form

**URL:** <https://www.ruby-forum.com/t/trying-to-link-to-edit-from-a-different-form/190037>\
**Category:** Rails\
**Created:** [June 11, 2010, 8:33pm UTC](https://www.ruby-forum.com/t/trying-to-link-to-edit-from-a-different-form/190037 "2010-06-11T20:33:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcmillhj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ab992/32.png) [@mcmillhj](https://www.ruby-forum.com/u/mcmillhj)\
**Post date:** [June 11, 2010, 8:33pm UTC](https://www.ruby-forum.com/t/trying-to-link-to-edit-from-a-different-form/190037/1 "2010-06-11T20:33:44Z")

</div>

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:

\<%= button\_to 'Decrease Date', {:controller =\> :bets, :id =\> Bet.find\_by\_milestone\_id(m.id), :action =\> :edit} %\>

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

Thanks,  
Hunter

---

<div class="post-metadata">

**Author:** ![mcmillhj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ab992/32.png) [@mcmillhj](https://www.ruby-forum.com/u/mcmillhj)\
**Post date:** [June 11, 2010, 9:23pm UTC](https://www.ruby-forum.com/t/trying-to-link-to-edit-from-a-different-form/190037/2 "2010-06-11T21:23:06Z")

</div>

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:
> 
> \<%= button\_to 'Decrease Date', {:controller =\> :bets, :id =\> Bet.find\_by\_milestone\_id(m.id), :action =\> :edit} %\>
> 
> 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:

\<%= 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 %\> \<%= 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 %\>

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
