Forum: Ruby on Rails Reusing a model to form and link_to.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
88ade3846f380b12dc27cada47138661?d=identicon&s=25 Fernando Lujan (Guest)
on 2006-05-09 17:41
(Received via mailing list)
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 Lujan
D0cd6b10e01bacb976b3b815a9c660bc?d=identicon&s=25 Alex Wayne (Guest)
on 2006-05-09 19:06
Fernando Lujan 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 Lujan

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"}) %>
This topic is locked and can not be replied to.