I have a Rails 4 application and just installed the Paperclip gem to handle image uploading. I can't get it working, after I've uploaded a photo it just says missing. Someone has a clue what's going wrong?
~settings/_form.html.erb
> <%= form_for(@setting, :html => { :multipart => true }) do |f| %>
> <% if @setting.errors.any? %>
> <div id="error_explanation">
> <h2><%= pluralize(@setting.errors.count, "error") %> prohibited this setting from being saved:</h2>
>
> <ul>
> <% @setting.errors.full_messages.each do |msg| %>
> <li><%= msg %></li>
> <% end %>
> </ul>
> </div>
> <% end %>
>
> <div class="field">
> <%= f.label :title %><br>
> <%= f.text_field :title %>
> </div>
> <div class="field">
> <%= f.label :description %><br>
> <%= f.text_area :description %>
> </div>
> <div class="field">
> <%= f.label :paragraph %><br>
> <%= f.text_area :paragraph %>
> </div>
> <div>
> <%= f.file_field :photo %>
> </div>
> <div class="actions">
> <%= f.submit %>
> </div>
> <% end %>
My setting model ~setting.rb
class Setting < ActiveRecord::Base
attr_accessible :title, :description, :paragraph
has_attached_file :photo
end
Photo Migration
class AddAttachmentPhotoToSettings < ActiveRecord::Migration
def self.up
change_table :settings do |t|
t.attachment :photo
end
end
def self.down
drop_attached_file :settings, :photo
end
end
Setting migration
class CreateSettings < ActiveRecord::Migration
def change
create_table :settings do |t|
t.string :title
t.text :description
t.text :paragraph
t.timestamps
end
end
end
~settings/Show.html.erb
<p id="notice"><%= notice %></p>
<p> <%= image_tag @setting.photo.url %> </p> <br />
<p>
<strong>Title:</strong>
<%= @setting.title %>
</p>
<p>
<strong>Description:</strong>
<%= @setting.description %>
</p>
<p>
<strong>Paragraph:</strong>
<%= @setting.paragraph %>
</p>
<%= link_to 'Edit', edit_setting_path(@setting) %> |
<%= link_to 'Back', settings_path %>
Can't figure out what's wrong. The uploaded photo does'nt show it just says "Missing". Would appreciate some help! :)