I was looking for a way to upload photos to a database and display photos on a page. I try a carrier wave. It loads the photo correctly, but when it appears to display the image, all it does is specify a location (url).
Loading here
class Image < ActiveRecord::Base attr_accessible :image, :title mount_uploader :image, ImageUploader end
Here is the form used to upload the file
<%= form_for @image, :html => {:multipart => true} do |f| %> <% if @image.errors.any? %> <div id="error_explanation"> <h2><%= pluralize(@image.errors.count, "error") %> prohibited this image from being saved:</h2> <ul> <% @image.errors.full_messages.each do |msg| %> <li><%= msg %></li> <% end %> </ul> </div> <% end %> <div class="field"> <%= f.label :image %><br /> <%= f.file_field :image %> </div> <div class="field"> <%= f.label :title %><br /> <%= f.text_field :title %> </div> <div class="actions"> <%= f.submit %> </div> <% end %>
This image display
<p id="notice"><%= notice %></p> <p> <b>Image:</b> <%= @image.image_url.to_s %> </p> <p> <b>Title:</b> <%= @image.title %> </p> <%= link_to 'Back', images_path %>
This is what prints:
Image: /uploads/image/image/2/946612_524939910875157_1455921715_n.jpg
Title: Poster
source share