我的rails应用程序遇到了一个非常令人困惑的问题。我试图在页面上显示图像,我知道路径是正确的。这由" test.html"验证,其全部内容为:
<img src="/Users/xxxxx/MHE_website/app/assets/images/aggi5.jpg" >
当我在本地加载此页面时,我会看到图片。但是,当我将它放入我的rails应用程序时,完全相同的文本不会加载。是什么赋予了?我注意到当我在本地托管进行开发时,我在终端中收到以下错误消息:
ActionController::RoutingError (No route matches [GET] "/Users/xxxxx/MHE_website/app/assets/images/aggi5.jpg"):
这是什么意思?我以前从来没有这样做过。以下是我的Gemfile,这可能或可能不相关,但我不知所措。
source 'https://rubygems.org'
#toggle this on for dev mode
# group :development, :test do
# gem 'sqlite3'
# end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.4'
# Use sqlite3 as the database for Active Record
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'owlcarousel-rails', '~> 1.1.3.3'
gem 'bootstrap-sass', '2.3.2.0'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', group: :development
group :development, :test do
gem 'sqlite3'
end
group :production, :staging do
gem 'pg'
gem 'rails_12factor'
end
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
答案 0 :(得分:1)
答案 1 :(得分:0)
尝试将图片权限更改为777
。它应该工作