Skip to content

Instantly share code, notes, and snippets.

@cameroncox
Forked from dannymcc/gist:3976163
Created October 29, 2012 20:01
Show Gist options
  • Save cameroncox/3976172 to your computer and use it in GitHub Desktop.
Save cameroncox/3976172 to your computer and use it in GitHub Desktop.
# app/models/activity.rb
class Activity < ActiveRecord::Base
serialize :details
end
# app/controllers/deploys_controller.rb
def create
payload = JSON.pare(params[:payload])
Activity.create!.tap do |activity|
activity.action = "change deployed"
activity.details = { :identifier => payload['identifier'], :name => payload['name'] }
activity.user = User.first
end
render :status => :created, :text => "success"
rescue ActiveRecord::RecordInvalid => e
render :status => :unprocessible_entity, :text => "an error has occured"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment