K
Kroeger, Simon (ext)
=20
or get them all at once:
per_page =3D @params.fetchper_page, 0).nonzero? || 20
cheers
Simon
-----Original Message-----
From: Jan Svitok [mailto:[email protected]]=20
Sent: Monday, August 28, 2006 4:01 PM
To: ruby-talk ML
Subject: Re: Newbie : assign a value to a variable...
=20
=20Thanks for the trick.
But the next problem is that if params[er_page] equals 0=20 then per_page
equals 0 and I get the error message "must have at least=20 one item per
page" from the Rails paginate option...
per_page =3D @params[er_page] || 20 # default
per_page =3D 20 if per_page <=3D 0 # validity check
=20
or the other way round:
=20
per_page =3D @params[er_page] # assignment
per_page =3D nil if per_page <=3D 0 # validity check
per_page ||=3D 20 # default
=20
Choose what you like best.
or get them all at once:
per_page =3D @params.fetchper_page, 0).nonzero? || 20
cheers
Simon