Skip to content

Instantly share code, notes, and snippets.

@tghastings
Created April 30, 2012 19:31
Show Gist options
  • Save tghastings/2561876 to your computer and use it in GitHub Desktop.
Save tghastings/2561876 to your computer and use it in GitHub Desktop.
## show.html.erb
<p>
<b>Title:</b>
<%= editable_field @project, :title %>
</p>
<p>
##project_controller.rb
def update
@project = Project.find(params[:id])
@project.update_attributes!(params[:project])
respond_to do |format|
if request.xhr?
# *** repond with the new value ***
render :text => params[:project].values.first
else
redirect_to(@project, :notice => 'P was successfully updated.')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment