Trouble with pagaination and conditional statements

i am trying to call this in my controller

if(maincategory == ‘sale’)
@pages, @viewobj = paginate_collection Sale.get_all_sales, :page =>
@params[:page]
end

if(maincategory == ‘job’)
@pages, @viewobj = paginate_collection Job.get_all_jobs, :page =>
@params[:page]
end

etc…

but for some reason, when i click on the page link number, i get a nil
error. however, when i just put the
@pages, @viewobj = … outside of the if statement, everything works
fine. i guess the maincategory field gets reset maybe?

how can i split this statement into to individual parts?

@pages, @viewobj = paginate_collection Job.get_all_jobs, :page =>
@params[:page]

is that the same as

@viewobj = paginate_collection(Job.get_all_jobs,:page => @params[:page])
@pages = paginate_collection(Job.get_all_jobs,:page => @params[:page])

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs