# Reusing a model to form and link\_to

**URL:** <https://www.ruby-forum.com/t/reusing-a-model-to-form-and-link-to/60033>\
**Category:** Rails\
**Created:** [May 9, 2006, 5:41pm UTC](https://www.ruby-forum.com/t/reusing-a-model-to-form-and-link-to/60033 "2006-05-09T17:41:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![flopezr333](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/54ee81/32.png) [@flopezr333](https://www.ruby-forum.com/u/flopezr333)\
**Post date:** [May 9, 2006, 5:41pm UTC](https://www.ruby-forum.com/t/reusing-a-model-to-form-and-link-to/60033/1 "2006-05-09T17:41:05Z")

</div>

Hy guys,

Inside my app I have a form which contains user information.

Sometimes a have a form with a text\_field as above:

\<%= form\_remote\_tag(:html =\> { :action =\> url\_for(:controller =\>  
“my\_controller”, :action =\> “my\_action”) }) %\>  
\<%= text\_field(‘my\_object’, ‘my\_parameter’, :maxlength =\> ‘30’ )%\>  
\<%= submit\_tag “Send”%\>  
\<%= end\_form\_tag %\>

In the controller I retrive the information using:

@my\_value = params[:my\_object][:my\_parameter]

OK.

In other parts I have a link\_to as:

\<%= link\_to(user.my\_value, :controller =\> “my\_controller”, :action =\>  
“my\_action”, XXXXXXX ) %\>

How can I change the XXXXXX to have the same behavior as I have  
previously?

Thanks in advance.

Fernando L.

---

<div class="post-metadata">

**Author:** ![flopezr333](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/54ee81/32.png) [@flopezr333](https://www.ruby-forum.com/u/flopezr333)\
**Post date:** [May 9, 2006, 7:06pm UTC](https://www.ruby-forum.com/t/reusing-a-model-to-form-and-link-to/60033/2 "2006-05-09T19:06:20Z")

</div>

Fernando L. wrote:

> Hy guys,
> 
> Inside my app I have a form which contains user information.
> 
> Sometimes a have a form with a text\_field as above:
> 
> \<%= form\_remote\_tag(:html =\> { :action =\> url\_for(:controller =\>  
> “my\_controller”, :action =\> “my\_action”) }) %\>  
> \<%= text\_field(‘my\_object’, ‘my\_parameter’, :maxlength =\> ‘30’ )%\>  
> \<%= submit\_tag “Send”%\>  
> \<%= end\_form\_tag %\>
> 
> In the controller I retrive the information using:
> 
> @my\_value = params[:my\_object][:my\_parameter]
> 
> OK.
> 
> In other parts I have a link\_to as:
> 
> \<%= link\_to(user.my\_value, :controller =\> “my\_controller”, :action =\>  
> “my\_action”, XXXXXXX ) %\>
> 
> How can I change the XXXXXX to have the same behavior as I have  
> previously?
> 
> Thanks in advance.
> 
> Fernando L.

Do you mean to have your link submit via ajax? Then you just use  
link\_to\_remote. And you probably shouldn’t be directly setting the  
action value of an ajax form. You should use this instead and lets the  
helper do its magic.

\<%= form\_remote\_tag(:url =\> {:controller =\>  
“my\_controller”, :action =\> “my\_action”}) %\>
