Hi I think I have a simple problem, but I just can''t find the solution
I just found a very simple sorting solution in a book something like
that
It works in the first page with localhost/faculdade?sort_by=name
but when u try to go to the next page it goes to
http://localhost:3000/faculdade?page=2 I know it should be
/page=2&sort_by=name but don''t know how to do it .....
Thanks in advance !
#on list.rhtml
<table border="1" cellpadding="5"
cellspacing="1">
<tr>
<th> <a href="?sort_by=nome">Name </a> </th>
<%= link_to ''Next page'', { :page =>
@faculdade_pages.current.next } if
@faculdade_pages.current.next %>
and on the controller
def list
sort_by = params[:sort_by]
@_pages, @faculdades = paginate :faculdades, :order => sort_by,
:per_page => 20
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
This should do the job.
<%= link_to ''Next page'', { :page =>
@faculdade_pages.current.next, :sort_by => params[:sort_by] } if
@faculdade_pages.current.next %>
On Apr 1, 12:39 pm, Adriano Lul
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> Hi I think I have a simple problem, but I just can''t find the
solution
> I just found a very simple sorting solution in a book something like
> that
> It works in the first page with localhost/faculdade?sort_by=name
> but when u try to go to the next page it goes
tohttp://localhost:3000/faculdade?page=2I know it should be
> /page=2&sort_by=name but don''t know how to do it .....
> Thanks in advance !
>
> #on list.rhtml
>
> <table border="1" cellpadding="5"
cellspacing="1">
> <tr>
> <th> <a href="?sort_by=nome">Name </a>
</th>
>
> <%= link_to ''Next page'', { :page =>
@faculdade_pages.current.next } if
> @faculdade_pages.current.next %>
>
> and on the controller
> def list
> sort_by = params[:sort_by]
> @_pages, @faculdades = paginate :faculdades, :order => sort_by,
> :per_page => 20
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Richard Luther wrote:> This should do the job. > <%= link_to ''Next page'', { :page => > @faculdade_pages.current.next, :sort_by => params[:sort_by] } if > @faculdade_pages.current.next %> > > > On Apr 1, 12:39 pm, Adriano Lul <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>problem solved, hopes it helps someone ... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---