Friday, February 17, 2012

[Rails] undefined method `key?' for nil:NilClass PaperClip

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.

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate