Created
September 12, 2008 15:50
-
-
Save tooky/10462 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
$('a#save').click(function(event){ | |
event.preventDefault(); | |
$.ajax({ | |
type: "POST", | |
url: '/items/' + id, | |
data: $(this).siblings('input').serializeArray(), | |
dataType: 'json' | |
}); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Items < ActiveRecord::Base | |
def update | |
@item = Items.find(params[:id]) | |
raise NotFound unless @item | |
if @item.update_attributes(params[:item]) | |
redirect url(:item, item) | |
else | |
raise BadRequest | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment