On Aug 28, 2006, at 10:15 AM, Luc H. wrote:
You can also do:
per_page = @params.fetch(:per_page, 20)
Thanks for that. I’ve been oblivious to the default and block
options for fetch!
Gary W.
On Aug 28, 2006, at 10:15 AM, Luc H. wrote:
You can also do:
per_page = @params.fetch(:per_page, 20)
Thanks for that. I’ve been oblivious to the default and block
options for fetch!
Gary W.
then per_page
per_page = nil if per_page <= 0 # validity check
per_page ||= 20 # defaultChoose what you like best.
or get them all at once:
per_page = @params.fetch(:per_page, 0).nonzero? || 20
cheers
Simon
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs