Created
April 16, 2014 23:28
-
-
Save andrewfree/10942142 to your computer and use it in GitHub Desktop.
MomentCreate
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
def create | |
# current_user = User.first | |
if moment_params.empty? | |
render status: 406, nothing: true and return | |
else | |
@moment = Moment.new(moment_params) | |
@moment.user_id = current_user.id | |
if @moment.save | |
render "moments/show", status: 201 and return | |
else | |
render status: 422, nothing: true and return # We should know about things like this. | |
puts "ERROR" | |
end | |
end | |
rescue ActiveRecord::RecordNotSaved => e | |
puts "ERROR " | |
@object.errors.full_messages | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment