Comments (7)
The Cause
I suspect this is caused here:
Line 14 in 73c1ca2
We are modifying the hash after it's been frozen.
Proposed Solution
- Just document it?
from pagy.
#pagy.rb
# Pagy initializer file (6.0.0) # default
Pagy::DEFAULT[:items] = 15 # default
Pagy::DEFAULT[:metadata] = %i[ first_url page_url prev_url next_url last_url ]
Pagy::I18n.load({ locale: 'de', filepath: 'config/locales/pagy-de.yml' },
{ locale: 'en', filepath: 'config/locales/pagy-en.yml' })
# When you are done setting your own default freeze it, so it will not get changed accidentally
- Pagy::DEFAULT.freeze
+ # Remove the default freeze line
from pagy.
The Pagy::Console
is meant to supply a mock environment to pagy, so it would work even without any app or configuration. If you actually want to just try pagy in its mock environment, you could just use irb
for a quick glance into pagy (without loading the rails env).
The use of Pagy::Console
in the rails c
is kind of hybrid. When you use the rails console, you are loading the rails environment (and the pagy.rb
initializer/configuration), hence you should be able to use pagy without the Pagy::Console
, by just running your own controllers and helpers in the console for a truthy/non-mocked output.
However if you actually want to use it in the rails c
you can temporarily comment out the Pagy::DEFAULT.freeze
, so allowing Pagy::Console
to set the DEFAULT[:url]
, or set it yourself to nil
in the console, in order to avoid changing the default pagy_url_for
behavior.
I don't know whether using it with rails c
would provide any advantage compared to use the actual controller/helper methods. If it does, please let me know. If it doesn't we should remove the rails console mention from the Pagy::Console
doc and eventually add a note explaining that there is no point to use it with an app environment.
from pagy.
Temporarily commenting out the Pagy::DEFAULT.freeze
line works. Thanks for the tip.
I was trying out a few things in setting the JSON response of the collection serializer using the pagy_metadata
. I Thought Pagy::Console
would be handy here and believe it would be.
Would there be a better way to make this module readily useful in rails c
? Any ideas on what could be possible if you believe this module is useful to stay? I could try and put something for you to have a look at.
from pagy.
Would there be a better way to make this module readily useful in rails c?
Pagy is agnostic, so no rails outside of the doc.
Any ideas on what could be possible if you believe this module is useful to stay? I could try and put something for you to have a look at.
I don't understand anything of what you mean here 🙃
from pagy.
My thoughts about rais env so far are that either you need the whole rails env to check the real pagy output, and in that case you don't need Pagy::Console
because you have everything accessible in the rails c
, OR you just want to play with a mocked env in order to familiarize with the pagy stuff, and in that case you don't need the rails env, hence irb
would be enough.
Mixing environments would just be confusing and would require more setup work than what you may save typing IMO.
Am I missing anything?
from pagy.
Closing in favour of #483.
Pls LMK if I've missed the mark. I've also simplified the wording.
from pagy.
Related Issues (20)
- Plain ruby file that can run as `ruby my-problem.rb` HOT 1
- Update build badge on README.md
- Release-gem workflow glitch HOT 1
- Update js build command
- Docs: Add id pagination suggestion in HowTo
- Docs: Tailwind template example HOT 3
- Docs: Add How To entry for "Paginate multiple collections in the same action" HOT 2
- Docs: Add How To entry for "Customize the displayed text" HOT 1
- Docs: Typo on I18n Extra page HOT 1
- Docs: Arel extra is missing from pagy.rb HOT 2
- Bug: Pagy seems to ignore #limit scope HOT 6
- Docs: Add better description for nav_js blocks HOT 1
- Docs: Update AJAX doc HOT 6
- Bug: Cannot load such file HOT 1
- Bug: "warning: the following paths have collided" when cloning the repo HOT 2
- Bug: Inconsistent Pagination Behavior with Specific Pagy Size Configuration HOT 6
- Docs: No documentation on how to set items per page in tests HOT 4
- Invalid count HOT 3
- `pagy_bootstrap_nav_js` not working - others are HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pagy.