Skip to content

Instantly share code, notes, and snippets.

@andrewfree
Created April 16, 2014 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andrewfree/10942142 to your computer and use it in GitHub Desktop.
Save andrewfree/10942142 to your computer and use it in GitHub Desktop.
MomentCreate
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