Forum: Ruby link_to with pagination

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
500d951370da06e01727a82446cde271?d=identicon&s=25 Chris (Guest)
on 2006-06-07 04:28
I need some help with pagination and the link_to in the view.

I'm trying to include a hash in the pagination link_to params and it
keeps flattening out my hash.

Example:
Here's my hash called @answer:
  "answer"=>{"6"=>"9bf31c7ff062936a96d3c8bd1f8f2ff3",
           "7"=>"6f4922f45568161a8cdf4ad2299f6d23"}

Here's the code in my view for my pagination link:
  	<%= link_to('next', {:params => 'answer' => @answer,
params.merge('page' => object_pages.current.previous,)}) + ' ' if
object_pages.current.previous %>

See how the link_to doesn't maintain the actual hash:
<a
href="/student_portal/evaluate_exam/7?commit=Submit+Test&amp;answer=69bf31c7ff062936a96d3c8bd1f8f2ff376f4922f45568161a8cdf4ad2299f6d23&amp;page=2">next</a>&nbsp;

Anyone know how I can pass a hash intact through a link_to ?

Thanks a ton!
500d951370da06e01727a82446cde271?d=identicon&s=25 Chris (Guest)
on 2006-06-07 04:31
Sorry slight error there in the view code (it actually looks like):
  <%= link_to('next', {:params => params.merge('answer' => @answer,
'page' =>
   object_pages.current.previous,)}) + ' ' if
object_pages.current.previous %>

Chris wrote:
> I need some help with pagination and the link_to in the view.
>
> I'm trying to include a hash in the pagination link_to params and it
> keeps flattening out my hash.
>
> Example:
> Here's my hash called @answer:
>   "answer"=>{"6"=>"9bf31c7ff062936a96d3c8bd1f8f2ff3",
>            "7"=>"6f4922f45568161a8cdf4ad2299f6d23"}
>
> Here's the code in my view for my pagination link:
>   	<%= link_to('next', {:params => params.merge('answer' => @answer, 'page' => 
object_pages.current.previous,)}) + ' ' if
> object_pages.current.previous %>
>
> See how the link_to doesn't maintain the actual hash:
> <a
> 
href="/student_portal/evaluate_exam/7?commit=Submit+Test&amp;answer=69bf31c7ff062936a96d3c8bd1f8f2ff376f4922f45568161a8cdf4ad2299f6d23&amp;page=2">next</a>&nbsp;
>
> Anyone know how I can pass a hash intact through a link_to ?
>
> Thanks a ton!
E34b5cae57e0dd170114dba444e37852?d=identicon&s=25 Logan Capaldo (Guest)
on 2006-06-07 07:39
(Received via mailing list)
On Jun 6, 2006, at 10:31 PM, Chris wrote:

>> keeps flattening out my hash.
>>
>
> --
> Posted via http://www.ruby-forum.com/.
>

Wrong mailing list

http://lists.rubyonrails.org/mailman/listinfo/rails
This topic is locked and can not be replied to.