<%= link_to_remote "From Date", :update =>
''content'', :url =>
courses_path(:sort => ''from_date''), :method => :get,
:before =>
"Element.show(''loading''), :complete =>
"Element.hide(''loading'')" %>
in controller, change the ''list'' action to be
''index''. List is not
used by the REST defaults
def index
@courses.find(:all, :order => params[:sort])
end
in your routes make sure you have
map.resources :courses
Don''t forget your checking when bringing in the params[:sort]
parameter
If you need custom routes for your REST app do this, but think about
the requirement first (it''s not a bad thing to do when you need it,
but often you don''t need it):
map.resources :courses, :collection = {:list_tagged => :get}, :member
=> {:enable => :put}
etc. Collection takes the pluralised controller name plus the method
you define, e.g. courses_search_path = ''/courses/search''
member takes the controller, plus a record selected by id, e.g.
course_enable_path(@course) = /courses/1/enable
On Jan 15, 4:42 am, Sumeru
<dearmon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I have written the following code for sorting list of courses:
>
> <%= link_to_remote "From Date", :update =>
''content'', :url =>
> {:controller=> "courses", :action =>
''list'', :sort =>
> ''from_date'' }, :before =>
"Element.show(''loading'')", :complete =>
> "Element.hide(''loading'')", :method =>
''get'' %>
>
> I want to change above code to REST architecture, I changed the url to
> courses_path, :sort =>''from_date. Its not working.
>
> Can u help me to make it in RESTful way.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---