Forum: Ruby on Rails how to do a simple update on the server from a change of a s

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Kelly F. (Guest)
on 2006-04-11 19:07
(Received via mailing list)
I have a list of items on a page. Each item has a select list. If
someone changes the select list I would like to update the appropriate
record on the server....nothing else. I suspect I am making this too

I have an action on my controller for updating this value. I just
tried the 'remote_function', ah, function. It invokes the action on
the controller but the the value of the select that it is connected to
is not sent.

I hope I am missing something simple.

The controller action is:

def update_status
  goal = Goal.find(params[:id])
  goal.status = params[:goal][:status]

The relevant form part looks like this

<%= select_tag('goal[status]', options_for_select(GoalStatus::STATES,
      goal.status), :onfiltered=> remote_function(:url =>
      :update_status, :id => goal })) %>

Asked another way, how can I send the value of the form element
associated with the remote_function?

Is there a better way to do this?

Kelly F. (Guest)
on 2006-04-11 21:43
(Received via mailing list)
I'm still working on this and still looking for help....  :-}

I've made a few changes. Now I'm using form_remote_tag and submitting
form with an onchange event. The form does get submitted. Even though
is nothing to update on the web page I specify an :update parameter and
the action do a render_partial. The action is being called. Now the
is that the partial gets displayed and nothing else. The output of the
partial refreshes the entire page instead of updating just the specified

Any suggestions?

Now my controller method looks like this:

  def update_status
    goal = Goal.find(params[:id])
    goal.status = params[:goal][:status]
    render :partial => 'list_row', :locals =>{:goal => goal}

my list_row partial looks like this (some rows deleted just to keep it

<div id="gl_<%= -%>">
    <td><%=h goal.goal -%></td>
    <td><%=h goal.task -%></td>
    <td><%=h goal.comments -%></td>
  <%= form_remote_tag(  :update => "gl_#{}",
                        :url => { :action => 'update_status', :id =>
    <%= select_tag('goal[status]',
goal.status), :onChange => 'this.form.submit()') -%>
  <%= end_form_tag -%>
This topic is locked and can not be replied to.