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

Conflict with paper_trail? #15

Closed
gamov opened this issue Jan 14, 2013 · 3 comments
Closed

Conflict with paper_trail? #15

gamov opened this issue Jan 14, 2013 · 3 comments

Comments

@gamov
Copy link

gamov commented Jan 14, 2013

Adding this gem to my app makes it crash on boot:

/Users/gamov/.rvm/gems/ruby-1.9.3-p327@ector/gems/activerecord-3.0.19/lib/active_record/named_scope.rb:132:in `valid_scope_name?': private method `warn' called for nil:NilClass (NoMethodError)
    from /Users/gamov/.rvm/gems/ruby-1.9.3-p327@ector/gems/activerecord-3.0.19/lib/active_record/named_scope.rb:102:in `scope'
    from /Users/gamov/.rvm/gems/ruby-1.9.3-p327@ector/gems/paper_trail-2.6.3/lib/paper_trail/version.rb:36:in `<class:Version>'
    from /Users/gamov/.rvm/gems/ruby-1.9.3-p327@ector/gems/paper_trail-2.6.3/lib/paper_trail/version.rb:1:in `<top (required)>'

It happens on the line:

  scope :between, lambda { |start_time, end_time|
    where(["#{PaperTrail.timestamp_field} > ? AND #{PaperTrail.timestamp_field} < ?", start_time, end_time ]).
      order("#{PaperTrail.timestamp_field} ASC, #{self.primary_key} ASC")
  }

because it tries to define another scope called :between.

What would be the best way to de-activate by_star in the application context? Maybe an initializer where we can specify which classes we want to include/exclude by_star scopes?

Update: I've created a blank 3.0 app and installed only by_star & paper_trail and I don't get the exception... mmm here comes gem dependencies nightmare...

@gamov
Copy link
Author

gamov commented Jan 14, 2013

Ok, I figured it out:
if you place:
gem 'by_star', :git => "git://github.com/radar/by_star"
BEFORE
gem 'paper_trail'
in your Rails 3.0.19 gem file, then you get the error above...

How is that possible?!?

@radar
Copy link
Owner

radar commented Jan 15, 2013

I have no idea how it's possible.

I'd rather not have to rename every method in by_star to ensure it doesn't conflict with things, but I think I could make an exception for between. Please rename this method to between_times in a new patch.

@johnnyshields
Copy link
Collaborator

This is a method name conflict defined on ActiveRecord::Base, plain and simple.

I've raised a PR to deprecate the between method for ActiveRecord at #33. I've removed it already for Mongoid since Mongoid natively defines between. Let's move this thread to #33.

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

3 participants