# Link change to dropdown list and back

**URL:** <https://www.ruby-forum.com/t/link-change-to-dropdown-list-and-back/116777>\
**Category:** Rails\
**Created:** [October 9, 2007, 6:37pm UTC](https://www.ruby-forum.com/t/link-change-to-dropdown-list-and-back/116777 "2007-10-09T18:37:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [October 9, 2007, 6:37pm UTC](https://www.ruby-forum.com/t/link-change-to-dropdown-list-and-back/116777/1 "2007-10-09T18:37:39Z")

</div>

So I posted this question yesterday and nobody replied back, so what I’m  
doing must be pretty ground breaking (haha, don’t I wish). I have some  
fields that I would really like to have filled out without putting them  
in a form. Basically I have a link that allows the user to edit if they  
so desire. When they click the link the link turns into a dropdown, at  
which point they make a selection and onchange or onblur their selection  
is re-displayed as a link and saved to the database. Any way, here is  
the code…

First I have a table where someone can enter an airline name:

 \<%= link\_to\_remote ' (Edit) ', :update =\> 'exclude\_1', :url =\> { :action =\> 'add\_exclude\_airline1', :id =\> @user.id } %\> 

Then in the controller a partial is rendered to display the dropdown  
menu:

def add\_exclude\_airline1  
@user = User.find\_by\_id( params[:id] )

```
if @user.exclude_air_1.nil?
  render :partial => 'exclude_airline1'
else
  render :partial => 'exclude_airline1'
end

```

end

In exclude\_airline1 I am calling a function that basically redirects me  
to an action which basically re-renders text back to the div. I am not  
sure what he :with is doing, however. The code looks like:

\<% func = remote\_function( :update =\> ‘exclude\_1’, :url =\> {:action =\>  
‘set\_exclude\_airline\_1’}, :with =\> “‘id=’ + escape(value)” ) -%\>

\<% @airlines = Airline.find( :all, :order =\> ‘name’ ) %\>

\<% if @user.exclude\_air\_1.nil? %\>

"\>  
\<%= options\_from\_collection\_for\_select @airlines, ‘id’, ‘name’ %\>

\<% else %\>

\<%= select “airlinemembership”, “membership”, Airline.find( :all, :order  
=\>  
‘name’ ).collect {|a| [a.name.downcase.capitalize, a.id]},  
:selected =\> Airline.find\_by\_id( @user.exclude\_airline\_1 ) %\>

\<% end %\>

The set\_exclude\_airline\_1 looks like:

def set\_exclude\_airline\_1  
puts “TEST1”  
render :text =\> “\<%= link\_to\_remote ‘TEST1’, :update =\>  
‘exclude\_1’, :url =\> { :action =\>  
‘add\_exclude\_airline1’, :id =\> @user.id } %\>”  
end

Basically all that is happening at this point is that when I go and  
select an item from the dropdown, instead of a link appearing with the  
selection everything just disapears. Anyone have any suggestions of what  
I am doing wrong? Thanks all,

-S

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [October 9, 2007, 7:07pm UTC](https://www.ruby-forum.com/t/link-change-to-dropdown-list-and-back/116777/2 "2007-10-09T19:07:25Z")

</div>

Getting a little closer. I have found the “render :text =\>” in the  
“set\_exclude\_airline\_1” is not rendering the link\_to\_remote but it does  
render simple text, so I need to find a way around that.

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [October 9, 2007, 8:41pm UTC](https://www.ruby-forum.com/t/link-change-to-dropdown-list-and-back/116777/3 "2007-10-09T20:41:50Z")

</div>

On 10/9/07, Shandy N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Getting a little closer. I have found the “render :text =\>” in the  
> “set\_exclude\_airline\_1” is not rendering the link\_to\_remote but it does  
> render simple text, so I need to find a way around that.

Use render :inline, not render :text

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [October 9, 2007, 10:01pm UTC](https://www.ruby-forum.com/t/link-change-to-dropdown-list-and-back/116777/4 "2007-10-09T22:01:25Z")

</div>

Bob S. wrote:

> On 10/9/07, Shandy N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Getting a little closer. I have found the “render :text =\>” in the  
> > “set\_exclude\_airline\_1” is not rendering the link\_to\_remote but it does  
> > render simple text, so I need to find a way around that.
> 
> Use render :inline, not render :text

That did it. Now everything works, thanks you very much!

-S
