Last active
October 2, 2015 05:58
-
-
Save nuwansh/2185033 to your computer and use it in GitHub Desktop.
Create Method
This file contains hidden or 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
@object = object.new(params[:object]) | |
respond_with(@object) do |format| | |
if @object.save | |
format.html { | |
flash[:notice] = "Created a new object successfully." | |
redirect_to objects_path | |
} | |
format.json { render :json => object.find(@object).to_json, :status => :created, :location => @object } | |
else | |
format.html { render :new } | |
format.json { render :json => @object.errors.to_json, :status => :unprocessable_entity } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment