RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: loureirorg
Site: http://fanzine.com.br
to avoid the readonly error, use "reset_counters" instead of "update_attribute":
Project.reset_column_information Project.all.find_each do |p| Project.reset_counters p.id, :tasks end
This doesn't work anymore in Rails 4.2. Instead, use rescue_from.
Example:
class ApplicationController < ActionController::Base rescue_from User::NotAuthorized, with: :deny_access # self defined exception rescue_from ActiveRecord::RecordInvalid, with: :show_errors rescue_from 'MyAppError::Base' do |exception| render xml: exception, status: 500 end protected def deny_access ... end def show_errors(exception) exception.record.new_record? ? ... end end
to avoid the readonly error, use "reset_counters" instead of "update_attribute":
This doesn't work anymore in Rails 4.2. Instead, use rescue_from.
Example: