Skip to content

Global config#13

Open
jonuts wants to merge 4 commits intobegriffs:masterfrom
jonuts:config
Open

Global config#13
jonuts wants to merge 4 commits intobegriffs:masterfrom
jonuts:config

Conversation

@jonuts
Copy link

@jonuts jonuts commented Jul 15, 2016

Allows accessing setup configuration from one global location (e.g. initializer). Global settings can be overridden in paginate call.

@@ -0,0 +1,3 @@
language: ruby
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a weird error on Travis and rubygems/bundler#3558 suggests adding sudo: false to .travis.yml to fix it.

@begriffs
Copy link
Owner

Thanks for the contribution, I've got a question.

What if your app itself stored a configuration value to pass as options to paginate rather than modifying a property on CleanPagination? This eigenclass stuff and running setup in order to change a value seems potentially confusing vs having the app explicitly pass an options argument. Can you share more about how it simplifies your application code?

@jonuts
Copy link
Author

jonuts commented Jul 16, 2016

Really I just wanted a way to override the invalid range message. I couldn't think of a better way to do it. If you have suggestions I'm all ears

@jonuts
Copy link
Author

jonuts commented Jul 16, 2016

And then once I pulled out the message variable into the config, I figured the other values should come along as well

@jonuts
Copy link
Author

jonuts commented Jul 18, 2016

Also, this doesn't change the fact that you can still send in options directly to the paginate method. It's a common pattern for rails plugins to take advantage of a setup-type initializer. I don't see the downside personally - more options is (usually) a good thing :)

Anyway, all I wanted to do was make the invalid range message changeable. If you would rather have that sent in the options hash directly to the paginate method that would be fine by me. My current use case has dozens of different paginated actions. I could just as easily use a stored options hash - as long as the invalid message is actually configurable. I personally prefer the initializer route, but no biggie one way or the other.

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.

2 participants

Comments