# How to do a simple update on the server from a change of a s

**URL:** <https://www.ruby-forum.com/t/how-to-do-a-simple-update-on-the-server-from-a-change-of-a-s/57510>\
**Category:** Rails\
**Created:** [April 11, 2006, 5:07pm UTC](https://www.ruby-forum.com/t/how-to-do-a-simple-update-on-the-server-from-a-change-of-a-s/57510 "2006-04-11T17:07:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aseldo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e95f7d/32.png) [@aseldo](https://www.ruby-forum.com/u/aseldo)\
**Post date:** [April 11, 2006, 5:07pm UTC](https://www.ruby-forum.com/t/how-to-do-a-simple-update-on-the-server-from-a-change-of-a-s/57510/1 "2006-04-11T17:07:56Z")

</div>

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  
difficult.

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]  
goal.save  
end

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?

Thanks

---

<div class="post-metadata">

**Author:** ![aseldo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e95f7d/32.png) [@aseldo](https://www.ruby-forum.com/u/aseldo)\
**Post date:** [April 11, 2006, 7:43pm UTC](https://www.ruby-forum.com/t/how-to-do-a-simple-update-on-the-server-from-a-change-of-a-s/57510/2 "2006-04-11T19:43:53Z")

</div>

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  
the  
form with an onchange event. The form does get submitted. Even though  
there  
is nothing to update on the web page I specify an :update parameter and  
have  
the action do a render\_partial. The action is being called. Now the  
problem  
is that the partial gets displayed and nothing else. The output of the  
partial refreshes the entire page instead of updating just the specified  
div.

Any suggestions?

Now my controller method looks like this:

def update\_status  
goal = Goal.find(params[:id])  
goal.status = params[:goal][:status]  
goal.save  
render :partial =\> ‘list\_row’, :locals =\>{:goal =\> goal}  
end

my list\_row partial looks like this (some rows deleted just to keep it  
brief)

 \<%=h goal.goal -%\> \<%=h goal.task -%\> \<%=h goal.comments -%\> \<%= form\_remote\_tag( :update =\> "gl\_#{goal.id}", :url =\> { :action =\> 'update\_status', :id =\> goal}) -%\> \<%= select\_tag('goal[status]', options\_for\_select(GoalStatus::STATES, goal.status), :onChange =\> 'this.form.submit()') -%\> \<%= end\_form\_tag -%\>
