clean_pagination icon indicating copy to clipboard operation
clean_pagination copied to clipboard

Global config

Open jonuts opened this issue 8 years ago • 4 comments

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

jonuts avatar Jul 15 '16 12:07 jonuts

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?

begriffs avatar Jul 15 '16 17:07 begriffs

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 avatar Jul 16 '16 19:07 jonuts

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

jonuts avatar Jul 16 '16 19:07 jonuts

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.

jonuts avatar Jul 18 '16 16:07 jonuts