I have this route:
avatar_add_from_collection POST /avatars/:avatar_id/add_from_collection(.:format) {:action=>"add_from_collection", :controller=>"avatars"}
and I am trying to create a link using link_to that uses post. The reason I need to do that is because (apparently) you can't put an image on a button using button_to.
<%= link_to inline_avatar(avatar.fetch_avatar_image(:thumb)), add_from_collection_avatar_path(avatar),:method=>:post%>
brings up
No route matches "/avatars/3/add_from_collection"
If I change the routes file to make this a GET it works just fine.
The link_to looks like
link_to inline_avatar(avatar.fetch_avatar_image(:thumb)), avatar_add_from_collection_path(avatar),:method=>:post
EDIT:
Jade::Application.routes.draw do
resources :avatar_categories do
delete :remove_item
end
resources :avatars do
member do
post 'add_from_collection', :on=>:member
end
end
resources :categories,:addresses,:calendars,:topics,:profile,:news,:account_setting
resources :boards do
member do
get :move
post :move_category
end
end
post 'avatars/display_collection'
get "user/index"
get 'login/index'
get 'login/new'
post 'login/create'
post 'login/authenticate'
get 'login/forgot_password'
put 'login/reset_password'
get 'login/logout' #post?
get 'admin/index'
get 'admin/app_settings'
get 'admin/user_settings'
get 'admin/avatars'
post 'admin/avatar_upload'
post 'admin/update_app_settings'
get 'news_configurations/index'
put 'news_configurations/update'
get 'message_board_configurations/index'
put 'message_board_configurations/update'
get 'profile_settings/edit'
开发者_StackOverflow中文版 post 'profile_settings/update'
resources :posts do
get :new,:edit
post :create,:update,:destroy
end
match '/login' => 'login#index', :as => 'login'
match '/admin' => 'admin#index', :as => 'admin'
resources :login do
get :index
post :authenticate,:logout
end
root :to => "news#index"
end
resources :avatars do
member do
post 'add_from_collection'
end
end
or
resources :avatars do
post 'add_from_collection', :on => :member
end
EDIT
This is wrong
resources :avatars do
member do
post 'add_from_collection', :on=>:member
end
end
use this
resources :avatars do
post :add_from_collection, :on=>:member
end
But looks like this won't help
精彩评论