Advertisement
Advertisement
| 07.17.2008 at 02:29AM PDT, ID: 23572549 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: |
# part of view showing search results
<table>
<%@people.each do |person|%>
<tr>
<%if params[:first_name]="1"%><div id="first_name"><td><%unless person.first_name.blank?%>
<%=@copyofperson = person; in_place_editor_field :copyofperson, :first_name, {}, :url => { :controller => 'person', :action => 'updateattribute', :id => person.id } %>
<%end%></td></div><%end%>
.
.
.
</tr>
<%end%>
</table>
#person controller
def updateattribute
@person = Person.find(params[:id])
i = params[:editorId]
j = i.split("_")
j.pop
j.pop
j.pop
j.pop
j.delete_at(0)
field_name = j.join("_")#Getting the field to be updated in field_name
@person.update_attribute "#{field_name}", "#{params[:value]}"
end
# updateattribute.rjs
page.replace_html 'first_name', :partial=>'first_name', :object=>@person
# _first_name.html.erb
<div class ="first_name">
<td><%=@copyofperson = @person; in_place_editor_field :copyofperson, :first_name, {}, :url => { :controller => 'person', :action => 'updateattribute', :id => @person.id } %></td>
</div>
|