Paginate not working because arguments become nil?!

i am now closer to figuring out my problem.

when calling this…

myview.rhtml…
call action ‘view’

controller myClass…
def view
getView(params[:category])
end

controller application.rb…
def getView(category)

@pages, @users = paginate_collection something.find_my_data(category),
:page => @params[:page]

render_to displays/mycustomview
end

the first page of the view is fine, but when i click on page 2, it says
that i have a nil object. i traced back and printed out to the screen
‘category’ in the application.rb file, and it turns out it goes NIL
after selecting the 2nd page!.. so how can this be fixed? for some
reason, this problem only ocurs when i need to pass a variable to my
paginate query object.

thanks for any help!

It looks like you’re relying on params[:category] to persist across
pages.
That won’t happen. You have to store it in the session hash. Then you
can
write code like:

def view

first visit, user supplies category

session[:category] = params[:category] if params[:category]

any visit, refer to session hash to get category value

getView(session[:category])
end

Hope this solves your problem.

koloa-2 wrote:

def view
end
thanks for any help!


Posted via http://www.ruby-forum.com/.


View this message in context:
http://www.nabble.com/-Rails--paginate-not-working-because-arguments-become-nil-!-tf2709904.html#a7555560
Sent from the RubyOnRails Users mailing list archive at Nabble.com.

hi steve,
thank you for responding. i will try this when i get home. appreciate
the help!

Steve R. wrote:

It looks like you’re relying on params[:category] to persist across
pages.
That won’t happen. You have to store it in the session hash. Then you
can
write code like:

def view

first visit, user supplies category

session[:category] = params[:category] if params[:category]

any visit, refer to session hash to get category value

getView(session[:category])
end

Hope this solves your problem.

koloa-2 wrote:

def view
end
thanks for any help!


Posted via http://www.ruby-forum.com/.


View this message in context:
http://www.nabble.com/-Rails--paginate-not-working-because-arguments-become-nil-!-tf2709904.html#a7555560
Sent from the RubyOnRails Users mailing list archive at Nabble.com.