1

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の出力に資産リソースの情報が含まれていない理由を誰でも説明できますか?

4

1 に答える 1

1

リソースのパス( ) を変更assetsすれば問題ありません。/assetsスタイル/画像/javasctipts を提供するために使用されるデフォルト パスとの競合を解決します。

これを試して:

resources :assets, path: '/my_assets' do 
于 2012-04-12T06:58:16.177 に答える