Model-Conductor-Controller fix

Written on 11:42:00 AM by S. Potter

The New Bamboo blog talked about Presenters & Conductors last month. The demonstration Rails application was broken, so the enclosed link to a zip file contains the fixes I made to get the application running as expected. The offending code was in lib/action_conductor/lib/action_conductor/errors.rb:


module ActiveRecord
  class Errors
   def add_conductor_errors_for(record, mapping)
    return if record.valid?
    record.errors.each do |attribute, message|
      self.add(mapping[attribute.to_sym], message)
    end
   end
  end
end

The fixed code changed one line as so:

module ActiveRecord
  class Errors
   def add_conductor_errors_for(record, mapping)
    return if record.valid? or record.new_record?
    record.errors.each do |attribute, message|
      self.add(mapping[attribute.to_sym], message)
    end
   end
  end
end

The fixed zip file can be found at my 4shared account and also fixes the minor view errors.

If you enjoyed this post Subscribe to our feed

No Comment

Post a Comment