i have a problem implementing a list action with its own route. here is what i have (just important parts) routes.rb
map.resources :posts
map.login "login" ,:controller => "user_sessions" ,:action => "new"
map.logout "logout" , :controller => "user_sessions" , :action => "destroy"
map.sort "sort" , :controller => "posts" , :action => "sort"
posts_controller.rb
class PostsController < ApplicationController
def index
logger.info "index params:::"+params.inspect
@posts = current_user.posts.paginate :page => params[:page], :order => 'created_at DESC'
end
end
def show
@post = Post.find(params[:id])
end
def edit
@post = Post.find(params[:id])
end
def sort
logger.info "sort params:::"+params.inspect
@posts=current_user.posts.paginate(:page=>params[:page],:order=> params[:sort].to_s )
if request.xml_http_request?
render :update do |page|
page.replace_html :posts , :partial => 'post'
end
end
end
end
I get this error ActiveRecord::RecordNotFound in PostsController#show
Couldn't find Post with ID=sort.
I think its because the app thinks that when i type http://localhost:3000/posts/sort i want to show element with id=sort.how can i fix that?? thank you in advance