Skip to content

Instantly share code, notes, and snippets.

@akinsgre
Created March 13, 2012 14:29
Show Gist options
  • Select an option

  • Save akinsgre/2029122 to your computer and use it in GitHub Desktop.

Select an option

Save akinsgre/2029122 to your computer and use it in GitHub Desktop.
Problem with ActiveRecord save/update
def update
@channel = Channel.find(params[:channel_id])
@status = 0
# check permissions
if @channel.user_id == current_user.id
# save data
@channel.options1 = params[:options]
logger.debug "Channel changes " + @channel.changes.to_s
if @channel.save
logger.debug "The save worked"
@status = 1
end
logger.debug "Finished trying to save "
end
# return response: 1=success, 0=failure
render :json => @status.to_json
end
Started POST "/channels/1/charts/1" for 127.0.0.1 at 2012-03-13 10:28:35 -0400
Processing by ChartsController#update as JSON
Parameters: {"options"=>"&title=Test", "channel_id"=>"1", "id"=>"1"}
User Load (0.2ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
Channel Load (0.5ms) SELECT `channels`.* FROM `channels` WHERE `channels`.`id` = 1 LIMIT 1
Channel changes {"options1"=>[nil, "&title=Test"]}
SQL (0.1ms) BEGIN
Window Load (1.3ms) SELECT `windows`.* FROM `windows` WHERE `windows`.`wtype` = 'status' AND (`windows`.channel_id = 1)
SQL (0.1ms) COMMIT
The save worked
Finished trying to save
Completed 200 OK in 261ms (Views: 6.2ms | ActiveRecord: 2.4ms)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment