我想这件事甚至在写之前就让我很开心我觉得它与Rails 3.1+中的资产管道功能有关。
我在routes.rb文件中定义了一个带有名称资产的路由。这是routes.rb文件:
resources :assets do
member do
get 'remove_template'
get 'all_sticker'
get 'download_sticker'
end
collection do
get 'failed_asset'
end
end
现在何时跑rake routes
:
sample_template_sticker_template GET /sticker_templates/:id/sample_template(.:format) sticker_templates#sample_template
update_copy_sticker_template PUT /sticker_templates/:id/update_copy(.:format) sticker_templates#update_copy
sticker_templates GET /sticker_templates(.:format) sticker_templates#index
POST /sticker_templates(.:format) sticker_templates#create
new_sticker_template GET /sticker_templates/new(.:format) sticker_templates#new
edit_sticker_template GET /sticker_templates/:id/edit(.:format) sticker_templates#edit
sticker_template GET /sticker_templates/:id(.:format) sticker_templates#show
PUT /sticker_templates/:id(.:format) sticker_templates#update
DELETE /sticker_templates/:id(.:format) sticker_templates#destroy
thank_you /thank_you(.:format) home#thank_you
home /welcome(.:format) home#index
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PUT /users/password(.:format) devise/passwords#update
login GET / devise/sessions#new
logout GET /logout(.:format) devise/sessions#destroy
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
products GET /products(.:format) products#index
POST /products(.:format) products#create
new_product GET /products/new(.:format) products#new
edit_product GET /products/:id/edit(.:format) products#edit
product GET /products/:id(.:format) products#show
PUT /products/:id(.:format) products#update
DELETE /products/:id(.:format) products#destroy
create_sticker_stickers GET /stickers/create_sticker(.:format) stickers#create_sticker
stickers GET /stickers(.:format) stickers#index
POST /stickers(.:format) stickers#create
new_sticker GET /stickers/new(.:format) stickers#new
edit_sticker GET /stickers/:id/edit(.:format) stickers#edit
sticker GET /stickers/:id(.:format) stickers#show
PUT /stickers/:id(.:format) stickers#update
DELETE /stickers/:id(.:format) stickers#destroy
正如您所见,我找不到任何为资产资源定义的路由,即使我可以访问我为routes.rb
中的资产定义的所有可用路由。
任何人都可以解释为什么rake routes
的输出不包含资产资源的信息。
答案 0 :(得分:1)
更改资源的路径(assets
),你会没事的!它将解决与用于提供样式/图像/ javasctipts的默认/assets
路径的冲突。
试试这个:
resources :assets, path: '/my_assets' do