Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't seem to work with Rails 2.3 #1

Open
kakra opened this issue Nov 19, 2010 · 2 comments
Open

Doesn't seem to work with Rails 2.3 #1

kakra opened this issue Nov 19, 2010 · 2 comments

Comments

@kakra
Copy link

kakra commented Nov 19, 2010

I'm having the following model:

class DistrictSection < ActiveRecord::Base
  belongs_to :district
  belongs_to :section

  validates_uniqueness_of :section_id, :scope => :district_id
  validates_presence_of   :district
  validates_presence_of   :section
  validate_on_create      :section_waste_type_not_flagged

  after_create :flag_section_with_waste_type!
  after_destroy :unflag_section_from_waste_type!

We are having an import function which produces huge amounts of this join model items and it is important not to run migrations or hooks during import. So I tried:

DistrictSection.without_callbacks :all do
  converted_district_sections = ...
  DistrictSection.create! converted_district_sections
end

But the hooks and validations are all still run. This is a Rails 2.3 application.

@cjbottaro
Copy link
Owner

Dang, this plugin is really old. Like Rails 1.x and 2.0.x old. I would love to update it for you asap, but I'm leaving for a 2 week vacation in about 2 hours.

Till then, you can do it the old fashion way of having an attr_accessor on your class, then checking it in your callbacks.

@kakra
Copy link
Author

kakra commented Nov 19, 2010

Yep, I've did that as a work-around... For the moment it works, so enjoy your vacation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants