Hello, I have a problem with the paperclip, I put on my GemFile
gem “paperclip”, “~> 2.6.0”
I create a migrate
class FileUpload < ActiveRecord::Migration
def up
change_table :projects do |t|
t.has_attached_file :image
end
end
def down
drop_attached_file :projects, :image
end
end
on my model I put
class Project < ActiveRecord::Base
has_attached_file :image, :styles => { :medium => “300x300>”, :thumb
=> “100x100>” }
end
and in my view I put
<%= form_for @project, :url => { :action => “create” }, :html => {
:multipart => true } do |f| %>
<%= f.label :title, "Título" %>
<%= f.text_field :title %><br />
<%= f.label :description, "Descrição" %>
<%= f.text_area :description %><br />
<%= f.label :image, "Imagem" %>
<%= f.file_field :image %><br />
<%= f.submit "Criar novo Projeto" %>
<% end %>
But when I go to my action, this errors show.
NoMethodError in ProjectsController#new
undefined method `key?’ for nil:NilClass
Rails.root: /home/felipe/rails/Younner
Application Trace | Framework Trace | Full Trace
Request
Parameters:
None
Show session dump
Show env dump
Response
Headers:
None
Thank you.
UPDATE:
I got make it work, but now another error is showing, when I put a
image, on my file_field the rails add a div error.
I don’t know why…