From: Nicolas Blanco Date: 2006-08-28T22:48:20+09:00 Subject: Re: Newbie : assign a value to a variable... Thanks for the trick. But the next problem is that if params[:per_page] equals 0 then per_page equals 0 and I get the error message "must have at least one item per page" from the Rails paginate option... unknown wrote: > Hi -- > > On Mon, 28 Aug 2006, Nicolas Blanco wrote: > >> end >> >> Is there a better way to do this (put the parameter in the variable if >> the parameter is not null, otherwise put 20) ? > > You can use the || (or) operator: > > per_page = @params[:per_page] || 20 > > > David -- Posted via http://www.ruby-forum.com/.