Thanks! I tried : per_page = @params[:per_page].to_i > 0 ? @params[:per_page] : 20 but in this case if @params[:per_page] = 'blahblah' it works, I get 20 in per_page but if @params[:per_page] = 6 or another integer I get : undefined method `>' for false:FalseClass from Rails... Nicolas. unknown wrote: > On Mon, 28 Aug 2006, Nicolas Blanco wrote: > >> 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... > >>> per_page = @params[:per_page] || 20 > > In that case, use the trinary operator. Call to_i on @params[:per_page] > if it could be nil, as you don't want to do that comparison with nil. > > per_page = @params[:per_page].to_i > 0 ? @params[:per_page] : 20 > > > Kirk Haines -- Posted via http://www.ruby-forum.com/.