bbenezech / papermill

Full-stack asset management for Ruby on Rails. With Paperclip, SWFUpload, jQuery, jgrow, Jcrop and Facebox.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to edit with papermill

EnriqueVidal opened this issue · comments

Hi,

I am using the latest version of papermill, and I can create attachments with it and display them in my views with no problem, I downloaded the demo app, and read this page and followed along, however I cant seem to be able to use upload_image nor upload_images under edit, the odd thing is that it only gives that problem on my edit action (Im using a partial that I render in both my new and edit action views just like the demo app).

I have double checked my models and controllers againts the demo app and the look alright.

This is the error I get:

/opt/local/lib/ruby/gems/1.8/gems/papermill-1.3.2/lib/papermill/form_builder.rb:46: warning: Object#id will be deprecated; use Object#object_id
SQL (0.1ms) SET SQL_AUTO_IS_NULL=0

Processing PostsController#show (for 127.0.0.1 at 2009-12-26 21:47:49) [GET]
Parameters: {"action"=>"show", "id"=>"edit", "controller"=>"posts"}
Post Columns (1.7ms) SHOW FIELDS FROM posts
Post Load (0.8ms) SELECT * FROM posts WHERE (posts.id = 0)

ActiveRecord::RecordNotFound (Couldn't find Post with ID=edit):
app/controllers/posts_controller.rb:30:in show' haml (2.2.2) rails/./lib/sass/plugin/rails.rb:19:inprocess'
/opt/local/lib/ruby/1.8/webrick/httpserver.rb:104:in service' /opt/local/lib/ruby/1.8/webrick/httpserver.rb:65:inrun'
/opt/local/lib/ruby/1.8/webrick/server.rb:173:in start_thread' /opt/local/lib/ruby/1.8/webrick/server.rb:162:instart'
/opt/local/lib/ruby/1.8/webrick/server.rb:162:in start_thread' /opt/local/lib/ruby/1.8/webrick/server.rb:95:instart'
/opt/local/lib/ruby/1.8/webrick/server.rb:92:in each' /opt/local/lib/ruby/1.8/webrick/server.rb:92:instart'
/opt/local/lib/ruby/1.8/webrick/server.rb:23:in start' /opt/local/lib/ruby/1.8/webrick/server.rb:82:instart'

Rendered rescues/_trace (40.8ms)
Rendered rescues/_request_and_response (1.4ms)
Rendering rescues/layout (not_found)
SQL (0.1ms) SET SQL_AUTO_IS_NULL=0

Processing PostsController#edit (for 127.0.0.1 at 2009-12-26 21:47:58) [GET]
Parameters: {"action"=>"edit", "id"=>"1", "controller"=>"posts"}
User Columns (2.2ms) SHOW FIELDS FROM users
User Load (0.4ms) SELECT * FROM users WHERE (users.id = 1)
roles_users Columns (1.3ms) SHOW FIELDS FROM roles_users
Role Load (2.0ms) SELECT * FROM roles INNER JOIN roles_users ON roles.id = roles_users.role_id WHERE (roles_users.user_id = 1 )
CACHE (0.0ms) SELECT * FROM users WHERE (users.id = 1)
Post Columns (1.6ms) SHOW FIELDS FROM posts
Post Load (0.8ms) SELECT * FROM posts WHERE (posts.id = 1)
Rendering template within layouts/application
Rendering posts/edit

ActionView::TemplateError (undefined method `base_class' for Array:Class) on line #18 of app/views/posts/_form.html.erb:
15:


16:
17: <%= f.label :image_gallery %>

18: <%= f.images_upload(:image_gallery) %>


19:
20: <%= f.label :post_image %>

21: <%= f.image_upload(:post_image) %>

papermill (1.3.2) lib/papermill/form_builder.rb:47:in `papermill_upload_tag'
papermill (1.3.2) lib/papermill/form_builder.rb:11:in `images_upload'
app/views/posts/_form.html.erb:18
haml (2.2.2) lib/haml/helpers/action_view_mods.rb:167:in `form_for'
app/views/posts/_form.html.erb:1
haml (2.2.2) lib/haml/helpers/action_view_mods.rb:13:in `render'
app/views/posts/edit.html.erb:3
haml (2.2.2) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (2.2.2) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (2.2.2) rails/./lib/sass/plugin/rails.rb:19:in `process'
papermill (1.3.2) lib/papermill/flash_session_cookie_middleware.rb:14:in `call'
/opt/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/opt/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/opt/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/opt/local/lib/ruby/1.8/webrick/server.rb:162:in `start'
/opt/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/opt/local/lib/ruby/1.8/webrick/server.rb:95:in `start'
/opt/local/lib/ruby/1.8/webrick/server.rb:92:in `each'
/opt/local/lib/ruby/1.8/webrick/server.rb:92:in `start'
/opt/local/lib/ruby/1.8/webrick/server.rb:23:in `start'
/opt/local/lib/ruby/1.8/webrick/server.rb:82:in `start'

Rendered rescues/_trace (64.1ms)
Rendered rescues/_request_and_response (0.4ms)
Rendering rescues/layout (internal_server_error)

Thanks in advance for taking the time to read this.

Here is my post.rb file:

class Post < ActiveRecord::Base
has_many :comments
belongs_to :user

validates_presence_of :title, :body

attr_accessible :title, :body, :timestamp

cattr_reader :per_page
@@per_page = 5

named_scope :latest, :order => 'created_at DESC', :limit => 20

papermill :thumbnail => {:width => 100, :height => 75} # catch-all for non-specified associations, will create assets/asset methods.
papermill :image_gallery, :class_name => ImageAsset, :images_only => true, :thumbnail => {:width => 75, :height => 100}

image_gallery association (set with define_method)

end

this is my form code:

<% form_for(@post) do |f| %>
<%= f.error_messages %>

<%= f.label :title %>
<%= f.text_field :title %>

<br />

<%= f.label :body %>
<br / >
<%= f.text_area    :body, :cols => 75, :rows => 35, :class => "mceEditor" %>

<br /><br />

<%= f.label :image_gallery %><br />
<%= f.images_upload(:image_gallery) %><br /><br />

<%= f.label :post_image %><br />
<%= f.image_upload(:post_image) %><br /><br />

<%= f.submit 'Submit' %>

<% end %>

Hello,

I just tried, I found no problem with your code.
The only thing I can think of is your @post is an instance of Array (???) when it should be an ActiveRecord::Base object.
Please check your @post object.

You also obviously have a routing problem (the "Couldn't find Post with ID=edit" part)

Weird. Have you found a solution meanwhile?