Ruby on Rails: удаление расширения файла из запроса изображения и перенаправление на 404 - PullRequest
0 голосов
/ 02 января 2019

Изображение находится в каталоге Rails по адресу public/images/subDir/X.png.

В среде разработки это прекрасно загружается.

В работе Rails удаляет расширение файла (.png)и вместо этого перенаправляет запросы на public/images/subDir/X, что приводит к 404.

Как заставить Rails не перенаправлять запросы на изображения, подобные этому?

Мы используем RoR 3.2.x.

Файл маршрутов ниже.

Test::Application.routes.draw do


    ###########################################################################
    # Designs
    ###########################################################################
    match '/design' => 'default#design'


    # The priority is based upon order of creation:
    # first created -> highest priority.
    root :to => 'default#home'

    # Sample of regular route:
    #   match 'products/:id' => 'catalog#view'
    # Keep in mind you can assign values other than :controller and :action
    match ':controller(/:action(/:id(.:format)))'

    # Catches all unknown requests
    match '*url' => 'default#error_404'


    # Sample of named route:
    #   match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
    # This route can be invoked with purchase_url(:id => product.id)

    # Sample resource route (maps HTTP verbs to controller actions automatically):
    #   resources :products

    # Sample resource route with options:
    #   resources :products do
    #     member do
    #       get 'short'
    #       post 'toggle'
    #     end
    #
    #     collection do
    #       get 'sold'
    #     end
    #   end

    # Sample resource route with sub-resources:
    #   resources :products do
    #     resources :comments, :sales
    #     resource :seller
    #   end

    # Sample resource route with more complex sub-resources
    #   resources :products do
    #     resources :comments
    #     resources :sales do
    #       get 'recent', :on => :collection
    #     end
    #   end

    # Sample resource route within a namespace:
    #   namespace :admin do
    #     # Directs /admin/products/* to Admin::ProductsController
    #     # (app/controllers/admin/products_controller.rb)
    #     resources :products
    #   end

    # You can have the root of your site routed with "root"
    # just remember to delete public/index.html.
    # root :to => "welcome#index"

    # See how all your routes lay out with "rake routes"

    # This is a legacy wild controller route that's not recommended for RESTful applications.
    # Note: This route will make all actions in every controller accessible via GET requests.
    # match ':controller(/:action(/:id(.:format)))'
end

1 Ответ

0 голосов
/ 02 января 2019

Проблема была вызвана орфографической ошибкой в ​​имени изображения, хотя неясно, почему расширение файла было удалено.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...