Kullanıcılarımın bazı avatarlarını almak istiyorum ancak genel klasörden resim sunmuyor gibi görünüyor.Raylar 4 - Genel klasörden bir görüntü sunulması
Ben bunu sunmaya çalışır ben
RAILS_ROOT/public/uploads/user/avatar/6/mh.jpg
bir dosya var basit hale getirmek için:
benim prowser içinde%img{:src=>"/uploads/user/avatar/6/mh.jpg"}
o kadar varılır:
<img src="/uploads/user/avatar/6/mh.jpg">
hangi (Bence) 'ye çevirir:
http://localhost:3000/uploads/user/avatar/6/mh.jpg
Ben klasörün izinlerini kontrol ettirin. Ben development.rb içinde folling ayarı fiske var:
config.serve_static_files = false
değişiklik yok.
Benim yolları vardır - tırmık yollara göre: Benim günlüğünde
Rails.application.routes.draw do
devise_for :users
concern :paginatable do
get '(page/:page)', :action => :index, :on => :collection, :as => ''
end
match 'albums/select' => 'albums/select', via: [:get, :post]
#get 'albums/show_stat' => 'albums#show_stat'
resources :albums, :concerns => :paginatable
match "photos/(year/:year)/(month/:month)/(day/:day)/(country/:country)" => "photos#index", :via => [:post, :get]
resources :photos, :except => [:create, :index]
get '/photos/:id/image/:size' => 'photos#image'
get '/photos/:id/display' => 'photos#display'
resources :catalogs
get '/catalogs/:id/dashboard' => 'catalogs#dashboard'
get '/catalogs/:id/get_catalog' => 'catalogs#get_catalog'
match "/catalogs/:id/edit" => "catalogs#edit", via: [:get, :post]
get "/catalogs/:id/destroy" => "catalogs#destroy"
get '/catalogs/authorize' => 'catalogs#authorize'
get '/catalogs/authorize_callback' => 'catalogs#authorize_callback'
#resources :localcatalogs, controller: 'catalogs', type: 'LocalCatalog', :concerns => :paginatable
match '/catalogs/:id/import' => 'catalogs#import', via: [:get, :post]
get '/locations/lookup'
resources :locations, :concerns => :paginatable
get '/locations/:id/view' => 'locations#view'
post 'bucket/:id/add' => 'bucket#add'
post 'bucket/:id/remove' => 'bucket#remove'
get 'bucket/list' => 'bucket#list'
get 'bucket' => 'bucket#index'
get 'bucket/clear' => 'bucket#clear'
get 'bucket/count' => 'bucket#count'
get 'bucket/save' => 'bucket#save_to_album'
get 'bucket/delete_photos' => 'bucket#delete_photos'
get 'doubles/find'
get 'doubles/index'
get 'doubles/:doubles_id/delete/:photo_id' => 'doubles#delete'
get 'administration/generate_albums'
get 'administration/jobs_pending'
get 'administration/list_jobs'
post 'jobs/list' => 'jobs#list'
resources :jobs
require 'resque/server'
mount Resque::Server.new, at: "/resque"
root to: 'photos#index'
end
alıyorum:
Started GET "/uploads/user/avatar/6/mh.jpg" for ::1 at 2016-03-18 22:38:07 +0100
ActionController::RoutingError (No route matches [GET] "/uploads/user/avatar/6/mh.jpg"):
actionpack (4.2.5) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
web-console (2.3.0) lib/web_console/middleware.rb:28:in `block in call'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `catch'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `call'
actionpack (4.2.5) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.5) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.5) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.5) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.5) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.5) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.5) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.5) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.4) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.5) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
İlk eğik çizgi olmadan denediniz mi? '/ uploads/...' yerine uploads/.. 'yerine – SteveTurczyn
Evet. Hiçbir değişiklik ... '/' olmadan, yol 'kullanıcı' olan modelle öneklenir – martin