Skip to content

Instantly share code, notes, and snippets.

@djgraham
Created February 2, 2012 16:04
Show Gist options
  • Save djgraham/1724238 to your computer and use it in GitHub Desktop.
Save djgraham/1724238 to your computer and use it in GitHub Desktop.
Really hacky way of assigning a "belongs_to" event with an attribute on the event that is allowed to change on create or update of a comment :/
def create
@event.update_attribute(:status_id, params[:comment][:event_attributes][:status_id])
params[:comment].delete(:event_attributes) # = nil # = {:id => params[:event_id]}
@comment = @event.comments.new(params[:comment])
if @comment.save
redirect_to admin_event_comments_path(@event), :flash => { :info => "Comment created" }
else
render :action => :edit
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment