Reusing a model to form and link_to

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.

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”}) %>