Reputation: 687
I'm having a very confusing problem with my rails app. I am trying to display an image on a page, and I know the path is correct. This is verified by "test.html", the entirety of which is:
<img src="/Users/xxxxx/MHE_website/app/assets/images/aggi5.jpg" >
And when I load this page locally I see the picture. However, the exact same text does not load when I put it into my rails app. What gives? I notice that when I am hosting locally for developing, I get the following error message in my terminal:
ActionController::RoutingError (No route matches [GET] "/Users/xxxxx/MHE_website/app/assets/images/aggi5.jpg"):
What does this mean? I've never had to do this before. The following is my Gemfile, this may or may not be relevant but I'm at a loss.
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]
Upvotes: 0
Views: 79
Reputation: 2534
You need to use image_tag
helper to display images in your application. See documentation.
You should use something like this in your view:
<%= image_tag( 'aggi5.jpg' ) %>
Upvotes: 1
Reputation: 1523
Try changing the permission of the image to 777
. It should work
Upvotes: 0