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:
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