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

Subclasses are including ActiveRecordModelExtension too fast #262

Closed
wants to merge 1 commit into from

Conversation

rindek
Copy link

@rindek rindek commented Jul 18, 2012

Hi,

In regard of this issue: https://github.com/amatsuda/kaminari/pull/119
Everything works fine, unless you want to change the configuration of Kaminari (for example change the page_method_name)

I'm using paper_trail in project, but I'm also kind of forced to change the page_method_name.
First paper_trail is loaded, then kaminari after ActiveSupport loads, then all 'subclasses' are having ActiveRecordModelExtension included, right with Version model which is provided by paper_trail, but unfortunately the extensions are loaded before the configuration file from project is loaded, therefore, Version model has default kaminari config, while other projects model have proper config.

I've changed active_record_extension to load subclasses when first model is 'loaded' in project.

@rindek
Copy link
Author

rindek commented Jul 27, 2012

Bump. Any updates on this @amatsuda?

@zzak
Copy link
Contributor

zzak commented Aug 7, 2013

I'm opposed to this change, the proposal is unclear. Please file a bug if you have an issue that is more specific.

@ktaragorn
Copy link

@rindek I tried to merge this with HEAD in my fork, however it broke with undefined method per_page_kaminari'` for ALL models. Is it possible to check if it is possible to fix this for the latest version of kaminari?

@zzak
Copy link
Contributor

zzak commented Nov 24, 2013

I understand this may still be a bug that we can fix, so I will re-open this ticket.

We should consider a way to lazy-load this feature maybe.

@zzak zzak reopened this Nov 24, 2013
@ktaragorn
Copy link

Small update to what I said earlier, I discovered that master without the fix was also giving me the same problem

@yuki24
Copy link
Member

yuki24 commented Mar 19, 2014

I just tried to reproduce this issue and confirmed that PaperTrail::Version class is loaded by Bundler. As a result, it always has page even when we have config/initializers/kaminari_config.rb.

However, a better fix could be to make paper_trail gem a Rails engine and move PaperTrail::Version into app/models/paper_trail/version.rb. If it is under app/models/.., #inherited_with_kaminari will get fired when it's loaded so everything will start working fine. And we don't want to add extra code to kaminari just for fixing edge cases like this since it seems like putting a bandaid.

I'll close this issue and file a new issue on paper_trail. Thanks guys for raising this issue!

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

Successfully merging this pull request may close these issues.

None yet

4 participants