Giter Club home page Giter Club logo

papermill's Introduction

Papermill

  • Asset management made easy, 10 minutes integration.

  • All-you-can-eat glue around Polymorphic Paperclip table, SWFUpload & JQuery.

  • Associate any image or list of images with any model and any key.

Install the gem

sudo gem install papermill

Try the demo

rails -m http://github.com/bbenezech/papermill/raw/master/demo.txt papermill-example

Out-of-the-box compatibility with :

  • Formtastic # use :as => :[image|asset](s)_upload

  • JGrowl # for notifications (included)

  • FaceBox # for popups (included)

  • Stringex # (or any String#to_url) for asset filename/url generation

Navigator minimal requirements:

  • IE6+

  • Flash 9+

  • Javascript ON

Check your audience.

Server requirements:

  • Rails 2.3.

  • Paperclip 2.3.1.1 (loaded with gem dependency)

  • Front web server serving static assets if present, and forwarding demand to rails if not. Any classic installation will do that by default.

  • NOT compatible with Heroku/S3

Installation

Once gem is installed

Generate the migration

./script/generate papermill_table PapermillMigration

Edit it and migrate

rake db:migrate

Copy static assets to your public directory

./script/generate papermill_assets

Create the option file config/initializers/papermill.rb

./script/generate papermill_initializer

Go have a look at config/initializers/papermill.rb

In environment.rb

...
Rails::Initializer.run do |config|
  ...
  config.gem papermill
end

In your layout

Quick version

Inside <head></head>

<%= papermill_stylesheet_tag %>

Before </body> (best practice for javascript loading)

<%= papermill_javascript_tag :with_jquery => "no_conflict" %>

You don’t need :with_jquery if load it by yourself. Pass “no_conflict” if you use the default Prototype library, or some other ‘$’ library (mootools..)

In a real-world production application, you could use something like this, and adapt it to your own needs

Inside <head></head>

<% unless @content_for_papermill_inline_js.blank? %>
  <%= javascript_include_tag "/facebox/facebox.js", "/jgrowl/jquery.jgrowl_minimized.js", "/papermill/jquery.Jcrop.min.js", "/swfupload/swfupload.js", "/papermill/papermill.js", :cache => "papermill" %>
  <script type="text/javascript">
    jQuery(document).ready(function() {
      <%= yield :content_for_papermill_inline_js %>
    }
  </script>
<% end %>

Before </body>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js" type="text/javascript"></script>
<% unless @content_for_papermill_inline_js.blank? %>
  <%= stylesheet_link_tag("/facebox/facebox.css", "/jgrowl/jquery.jgrowl.css", "/Jcrop/jquery.Jcrop.css", "/papermill/papermill.css", :cache => "papermill") %>
  <style type="text/css">
    <%= yield :papermill_inline_css %>
  </style>
<% end %>

Security

URL-hacking

Maybe you don’t want users to use your application as a thumbnailing farm for their own uploaded images, or you have protected members areas and you don’t want users to ‘browse’ others members file.

  • Brute solution: pass :use_url_key to true in the options (config/initializers/papermill.rb). A crypted hash unique to your application and to each asset and to the requested style will be added to the URL. No more happy-guessing of anything. Do that first before going live, or you’ll have to migrate all assets…

  • pass :alias_only to true. This will disable the possibility to generate thumbnails with a papermill string in the url, but won’t do anything for the member area thing. Plus you will have to use aliases only, form helpers included (pass :thumbnail => { :style => :some_alias })

Usage

Assetable is the class that has_many papermill_assets (i.e. the class with the papermill declaration)

Assetable declaration

You can have one :default association (his settings will be used for unfound associations) and as many other associations as you want in your model. You can define a papermill relationship dynamically: just do smtg like Assetable.papermill(:dynamic_key, {}) when you need to. Perfect for CMS where associations are created by users. Then you’ll be able to use assetable.dynamic_key to retrieve the associated assets. If you don’t send the {}, default options from default association will be used, which may or may not be what you want.

Actually, the form helper leverages this when you use a :key that doesn’t exist: it will create a new Papermill relationship whith :key as the name and options from the :default declaration if any found on the model.

If you don’t need dynamic keys, just declare your associations in the model, like this :

class Article
  papermill :default
  papermill :images
  papermill :pdf_version
  papermill :cover_image
  papermill :illustrations
end

Form helpers

Example form:

form_for @assetable do 
  # I need a simple asset upload field :
  f.asset_upload  :pdf_version

  # Now I need to be able to upload as many documents as I need, and sort them at will
  # no document should be bigger than 1MB (respect the quoting!)
  # and I don't want the mass_edit feature
  f.assets_upload :documentation, :swfupload => { :file_size_limit => "'1 MB'" }, :mass_edit => false

  # I need to display *one* cover *image*, format will be 200x200
  # targetted_size will give the uploader hints when cropping the image after upload : desired display size and wanted aspect-ratio.
  # Better than cropping automatically in the center if the character's head is in the upper-left corner..
  # :thumbnail => { :width & :height } set the dimensions of the preview thumbnail
  # And finally, I need a 200x200# crop for preview, not the default 200x200> that would be generated by default ("#{:width}x#{:heigth}>")
  f.image_upload  :cover_image, :targetted_size => "200x200", :thumbnail => { :width => 200, :height => 200, :style => "200x200#" }

  # Now the image gallery, sortable.
  # I use :gallery => { :lines & :columns } to give the number of lines/columns,
  # and some CSS will be generated to size the gallery perfectly,
  # according to the thumb size inside the gallery and their padding/margin/border sizes.
  # the number of lines will increase if needed when uploading
  f.images_upload :illustrations, { 
    :thumbnail => {
      :width => 100,
      :height => 70
    },
    :gallery => {
      :columns => 8,       # number of columns
      :lines => 2,         # number of lines
      :vpadding => 2,      # vertical padding around each thumb
      :hpadding => 2,      # horizontal one
      :vmargin => 3,       # vertical margin
      :hmargin => 1,       # horizontal one
      :border_thickness => 2 # border size around each thumb
    } 
  }
end

With Formtastic, pass

:as => (:image_upload | :images_upload | :asset_upload | :assets_upload)

And add your options as you would with the normal helpers.

With FormTagHelpers, use (image_upload_tag | images_upload_tag | asset_upload_tag | assets_upload_tag) @assetable, :key, options

image_upload_tag  @article, :cover_image, :targetted_size => "200x200"

Asset editing

  • double-click on any uploaded asset in any form-helper to access & edit his properties

  • then double-click image to crop it if it’s an image. You’ll then access a Jcrop window. Pass :targetted_size => “widthxheigth” to lock aspect-ratio and default the selection size to widthxheigth.

Thumbnails

On-the-fly request time processing:

PapermillAsset#url(papermill string (see 1.))  # path and url behave the same way
PapermillAsset#url(papermill alias (see 2.))

Pros: fast. Nothing done upon page rendering. If asset isn’t found by Apache/NGinx, then request is passed to rails, which will create it, once.

Cons: need to setup an alias in the options if you want to define use a hash instead of a papermill string (for custom watermark)

Render time processing:

PapermillAsset#url!(papermill string (see 1.))  # path! and url! behave the same way
PapermillAsset#url!(papermill alias (see 2.))
PapermillAsset#url!(papermill hash (see 3.))

Pros: can use a hash directly in the url call.

Cons: needs a thumbnail presence check at each render.

1. Papermill String

Consist of:

  • an ImageMagick geometry string (ex: “100x100>”, “original”, “100x#”, etc.)

  • an optional watermark (-wm) flag # will use option for URI

  • an optional copyright (©) flag # will use copyright text after the “©” or options

Examples:

image_tag @article.covers.first.url("100x100")
image_tag @article.covers.first.url("original©")
image_tag @article.covers.first.url("100x100#-wm©")
image_tag @article.covers.first.url("100x200#©papermill")

2. Papermill Alias

Those are application-wide, set them in the options

Consist of:

:geometry => "ImageMagick-geometry-string"
:copyright => true | "copyright"    # If true, the asset copyright field will be used. Edit the asset.
:watermark => true | URI            # If true, will use options[:watemark]

Examples:

#config/initilializers/papermill.rb

# snip
:aliases => {
  :thumb_copyrighted => {
    :geometry => "100x100",
    :copyright => "papermill",
  },
  :thumb_copyrighted_dynamically => {
    :geometry => "100x100",
    :copyright => true
  },
  :thumb_watermarked_with_rails => {
    :width => "100",
    :height => "100",
    :watermark => "/images/rails.png"
  }
}

Then in your views, simply do

image_tag @article.covers.first.url(:thumb_copyrighted)

3. Papermill Hash

Same as aliases, but defined directly in #url!() Plus you can add a :name that will be used for style-name (defaults to a md5 of the hash)

Example:

image_tag @article.covers.first.url(
  :geometry => "100x100",
  :watermark => "/images/rails.png",
  :copyright => "papermill",
  :name => "thumbnail_watermarked_and_copyrighted"
)

Resource access

Papermill generates an #<association_key> association

@entry.mug_shots.first
@entry.diaporamas.each do |image| ..
# etc.

Using PapermillAsset

@asset = @entry.mug_shots.first
image_tag @asset.url              # original
image_tag @asset.url("100x>")     # assuming asset is an image
image_tag @asset.url(:big)        # assuming you have a :big alias
@asset.name
@asset.content_type
@asset.path
@asset.path("100x>")
# etc.

Translations:

Papermill is fully I18n-able. Copy config/locales/papermill.yml to your root config/locale folder to modify any wording in a any locale.

Copyright © 2009 Benoit Bénézech, released under the MIT license

papermill's People

Contributors

bbenezech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

yortz pombredanne

papermill's Issues

Any plans for a Rails 3 branch?

I'm getting:

/Users/Brightspark/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0/lib/active_record/base.rb:1016:in method_missing': undefined methodbefore_post_process' for #Class:0x00000100f509f0 (NoMethodError)

Also getting a deprecation warning about using the constant RAILS_ROOT.

Multiple words model name

Hi,
I'm reporting a bug using papermill on a multiple words model name.

I.e., if you apply papermill on a model named "BuyingLead" the image upload form crash with wrong ids. The bug is due to a composite name "Buying" + "Lead".
PaperMill generate markup with id like

, with a lot of underscores, dropping the model name.

Could u fix the bug?
Thanks
Mick

rails3

Hi Benoit,

Wondering if you have this working with Rails3 yet.

I just tried to add it into a rails3.01 project and got this when I do 'rails g' (looking for the papermill generator)

k@mark-solo:~/rails_apps/rails3/hoven$ rails g
DEPRECATION WARNING: RAILS_ROOT is deprecated. Please use ::Rails.root.to_s. (called from <top (required)> at /home/mark/rails_apps/rails3/hoven/config/application.rb:7)
/home/mark/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.1/lib/active_record/base.rb:1016:in method_missing': undefined methodbefore_post_process' for #Class:0x000000035381f0 (NoMethodError)
from /home/mark/.rvm/gems/ruby-1.9.2-p0/gems/papermill-2.1.1/lib/papermill/papermill_asset.rb:9:in <class:PapermillAsset>' from /home/mark/.rvm/gems/ruby-1.9.2-p0/gems/papermill-2.1.1/lib/papermill/papermill_asset.rb:1:in<top (required)>'
from /home/mark/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in require' from /home/mark/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:inblock in require'
from /home/mark/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:225:in block in load_dependency' from /home/mark/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:591:innew_constants_in'
from /home/mark/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:225:in load_dependency' from /home/mark/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:inrequire'
from /home/mark/.rvm/gems/ruby-1.9.2-p0/gems/papermill-2.1.1/lib/papermill.rb:26:in <top (required)>' from /home/mark/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.3/lib/bundler/runtime.rb:64:inrequire'
from /home/mark/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.3/lib/bundler/runtime.rb:64:in block (2 levels) in require' from /home/mark/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.3/lib/bundler/runtime.rb:62:ineach'
from /home/mark/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.3/lib/bundler/runtime.rb:62:in block in require' from /home/mark/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.3/lib/bundler/runtime.rb:51:ineach'
from /home/mark/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.3/lib/bundler/runtime.rb:51:in require' from /home/mark/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.3/lib/bundler.rb:112:inrequire'
from /home/mark/rails_apps/rails3/hoven/config/application.rb:7:in <top (required)>' from /home/mark/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.1/lib/rails/commands.rb:15:inrequire'
from /home/mark/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.1/lib/rails/commands.rb:15:in <top (required)>' from script/rails:6:inrequire'
from script/rails:6:in `

'

Hope all is well.
Mark

Thumb regeneration every time the page is requested

Hi,
in a production server, when I call:
product.pics[0].url("938x340#")

the resizing process is performed every time the page is requested and the gem doesn't use the already cached file in:
/public/system/papermill/000/000/015/938x340#/xxxx.jpg

This implies a waste of cpu resourses and it slow the page rendering.
Do I miss any configuration statement?
Thanks for the kindly reply.
Best Regards,
Mick

Where can I specify allowed file types?

I have a ticket model which will permit asset uploads (PDF, ZIP, DOC, XLS, etc). I do not have a model for the attachment.

class Ticket < ActiveRecord::Base
  papermill :attachments
end

I have the following line in config/initializers/papermill.rb:

:images_only => false,

I get the following growl feedback after the file has transferred:

36341.DOC
File is not one of the allowed file types.

I'm just wondering where I can explicitly permit certain extensions, or content types without having an attachment model?

Problems on windows...

Hi,
there are some problems on windows. When papermill try to generate the thumbnails, I receive the following message:

Errno::EINVAL in PapermillController#show

Invalid argument - /C:

RAILS_ROOT: C:/Documents and Settings/michele/Documenti/Projects/rails/business
Application Trace | Framework Trace | Full Trace

C:/ruby186/lib/ruby/1.8/fileutils.rb:243:in mkdir' C:/ruby186/lib/ruby/1.8/fileutils.rb:243:infu_mkdir'
C:/ruby186/lib/ruby/1.8/fileutils.rb:217:in mkdir_p' C:/ruby186/lib/ruby/1.8/fileutils.rb:215:inreverse_each'
C:/ruby186/lib/ruby/1.8/fileutils.rb:215:in mkdir_p' C:/ruby186/lib/ruby/1.8/fileutils.rb:201:ineach'
C:/ruby186/lib/ruby/1.8/fileutils.rb:201:in mkdir_p' C:/ruby186/lib/ruby/gems/1.8/gems/papermill-1.2.0/lib/papermill/papermill_asset.rb:115:increate_thumb_file'
C:/ruby186/lib/ruby/gems/1.8/gems/papermill-1.2.0/app/controllers/papermill_controller.rb:6:in show' C:/ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:1331:insend'
C:/ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:1331:in perform_action_without_filters' C:/ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:617:incall_filters'
C:/ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:610:in perform_action_without_benchmark' C:/ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:inperform_action_without_rescue'
C:/ruby186/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in ms' C:/ruby186/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:10:inrealtime'
C:/ruby186/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in ms' C:/ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:inperform_action_without_rescue'
C:/ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/rescue.rb:160:in perform_action_without_flash' C:/ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/flash.rb:146:inperform_action'
C:/ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:532:in send' C:/ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:532:inprocess_without_filters'
C:/ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:606:in process' C:/ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:391:inprocess'
C:/ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:386:in call' C:/ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:437:incall'

I've done some debug... The path papermill try to manage is:
/C:/Documents and Settings/michele/Documenti/Projects/rails/business/public/system/papermill/000/000/038/original/dm.jpg
where the first "/" is wrong on Windows systems. Could u patch your great gem?

Getting (Can't convert true into String)

I'm getting this exception:

TypeError (can't convert true into String):
papermill (1.3.5) app/controllers/papermill_controller.rb:13:in eval' papermill (1.3.5) app/controllers/papermill_controller.rb:13:inauthorize_create'
papermill (1.3.5) lib/papermill/flash_session_cookie_middleware.rb:14:in call' passenger (2.2.5) lib/phusion_passenger/rack/request_handler.rb:95:inprocess_request'
passenger (2.2.5) lib/phusion_passenger/abstract_request_handler.rb:207:in main_loop' passenger (2.2.5) lib/phusion_passenger/railz/application_spawner.rb:378:instart_request_handler'
passenger (2.2.5) lib/phusion_passenger/railz/application_spawner.rb:336:in handle_spawn_application' passenger (2.2.5) lib/phusion_passenger/utils.rb:183:insafe_fork'
passenger (2.2.5) lib/phusion_passenger/railz/application_spawner.rb:334:in handle_spawn_application' passenger (2.2.5) lib/phusion_passenger/abstract_server.rb:352:insend'
passenger (2.2.5) lib/phusion_passenger/abstract_server.rb:352:in main_loop' passenger (2.2.5) lib/phusion_passenger/abstract_server.rb:196:instart_synchronously'
passenger (2.2.5) lib/phusion_passenger/abstract_server.rb:163:in start' passenger (2.2.5) lib/phusion_passenger/railz/application_spawner.rb:213:instart'
passenger (2.2.5) lib/phusion_passenger/spawn_manager.rb:262:in spawn_rails_application' passenger (2.2.5) lib/phusion_passenger/abstract_server_collection.rb:126:inlookup_or_add'
passenger (2.2.5) lib/phusion_passenger/spawn_manager.rb:256:in spawn_rails_application' passenger (2.2.5) lib/phusion_passenger/abstract_server_collection.rb:80:insynchronize'
passenger (2.2.5) lib/phusion_passenger/abstract_server_collection.rb:79:in synchronize' passenger (2.2.5) lib/phusion_passenger/spawn_manager.rb:255:inspawn_rails_application'
passenger (2.2.5) lib/phusion_passenger/spawn_manager.rb:154:in spawn_application' passenger (2.2.5) lib/phusion_passenger/spawn_manager.rb:287:inhandle_spawn_application'
passenger (2.2.5) lib/phusion_passenger/abstract_server.rb:352:in __send__' passenger (2.2.5) lib/phusion_passenger/abstract_server.rb:352:inmain_loop'
passenger (2.2.5) lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'

This is the options hash being passed in, appears to come from the gallery=>"true" option:

Processing PapermillController#create (for 127.0.0.1 at 2010-02-10 16:22:29) [POST]
Parameters: {"Filename"=>"img136.jpg", "thumbnail_style"=>"75x100>", "Fileid"=>"SWFUpload_0_0", "action"=>"create", "assetable_type"=>"Job", "Upload"=>"Submit Query", "assetable_id"=>"8", "gallery"=>"true", "controller"=>"papermill", "assetable_key"=>"customer_photo", "asset_class"=>"CustomerPhoto", "Filedata"=>#File:/tmp/RackMultipart20100210-8175-1tki9nd-0}

I upgraded from Papermill 1.3.3 to 1.3.5, are there any changes I need to make to the generated database table to make this work?

Unable to edit with papermill

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.

Uncaught exception: undefined method `has_attached_file'

Hi,
today I updated my gems. "PaperClip" was updated to the 2.3.3 version.

Now, when I start my web-brick, it want not to start. The message is the following:
=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1959:in method_missing_without_paginate' C:/Ruby187/lib/ruby/gems/1.8/gems/will_paginate-2.3.14/lib/will_paginate/finder.rb:170:inmethod_missing'
C:/Ruby187/lib/ruby/gems/1.8/gems/papermill-2.0.2/lib/papermill/papermill_asset.rb:4
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require' C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in require' C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:innew_constants_in'
C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in require' C:/Ruby187/lib/ruby/gems/1.8/gems/papermill-2.0.2/lib/papermill.rb:29 C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require'
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in require' C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:inrequire'
C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in new_constants_in' C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:inrequire'
C:/Ruby187/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:208:in load' C:/Ruby187/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:307:inload_gems'
C:/Ruby187/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:307:in each' C:/Ruby187/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:307:inload_gems'
C:/Ruby187/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:164:in process' C:/Ruby187/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:insend'
C:/Ruby187/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in run' F:/Michele/Projects/Rails/saporitipici/config/environment.rb:9 C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require'
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in require' C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:inrequire'
C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in new_constants_in' C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:inrequire'
C:/Ruby187/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:84
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require' C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
./script\server:3
C:/Ruby187/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.9/lib/ruby-debug-ide.rb:109:in debug_load' C:/Ruby187/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.9/lib/ruby-debug-ide.rb:109:indebug_program'
C:/Ruby187/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.9/bin/rdebug-ide:87
C:/Ruby187/bin/rdebug-ide:19:in load' C:/Ruby187/bin/rdebug-ide:19 Uncaught exception: undefined methodhas_attached_file' for #Class:0x9090978


Where is the problem?
Papermill doen't compatible with the new Paperclip gem?

Many thanks for your kindly support,
Cheers,
Mick

Index name too long for MySQL

Hi, Im not a proficient Rails developer, so I don't know (and I searched for it) how to specify index names on rails migrations, so I decided to bring this to your attention, when changing the database backend to mysql and running the migrations I get:

An error has occurred, all later migrations canceled:

Mysql::Error: Identifier name 'index_papermill_assets_on_assetable_type_and_assetable_id_and_assetable_key_and_position' is too long: CREATE INDEX index_papermill_assets_on_assetable_type_and_assetable_id_and_assetable_key_and_position ON papermill_assets (assetable_type, assetable_id, assetable_key, position)

The index name is indeed long:

index_papermill_assets_on_assetable_type_and_assetable_id_and_assetable_key_and_position

Getting exception only with PDF file

Hey Sorry, one more exception. This is what I'm getting on upload of a PDF file, images are working fine:

Processing PapermillController#create (for 192.168.0.3 at 2010-02-11 08:56:50) [POST]
Parameters: {"Filename"=>"5206.pdf", "Fileid"=>"SWFUpload_0_0", "action"=>"create", "assetable_type"=>"Customer", "Upload"=>"Submit Query", "assetable_id"=>"16", "gallery"=>"true", "controller"=>"papermill", "assetable_key"=>"invoice", "asset_class"=>"CustomerInvoice", "Filedata"=>#File:/tmp/RackMultipart20100211-31877-e8i1ha-0}

NameError (undefined local variable or method page' for #<PapermillController:0x7f71373f7bb8>): papermill (1.3.6) app/controllers/papermill_controller.rb:44:increate'
papermill (1.3.6) lib/papermill/flash_session_cookie_middleware.rb:14:in call' passenger (2.2.8) lib/phusion_passenger/rack/request_handler.rb:92:inprocess_request'
passenger (2.2.8) lib/phusion_passenger/abstract_request_handler.rb:207:in main_loop' passenger (2.2.8) lib/phusion_passenger/rack/application_spawner.rb:114:inrun'
passenger (2.2.8) lib/phusion_passenger/rack/application_spawner.rb:65:in spawn_application' passenger (2.2.8) lib/phusion_passenger/utils.rb:184:insafe_fork'
passenger (2.2.8) lib/phusion_passenger/rack/application_spawner.rb:58:in spawn_application' passenger (2.2.8) lib/phusion_passenger/rack/application_spawner.rb:41:inspawn_application'
passenger (2.2.8) lib/phusion_passenger/spawn_manager.rb:159:in spawn_application' passenger (2.2.8) lib/phusion_passenger/spawn_manager.rb:287:inhandle_spawn_application'
passenger (2.2.8) lib/phusion_passenger/abstract_server.rb:352:in __send__' passenger (2.2.8) lib/phusion_passenger/abstract_server.rb:352:inmain_loop'
passenger (2.2.8) lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'

File permission issue

Hi,

I'm having trouble with uploaded files having a -rw------- permission. This causes the resulting thumbnail to not be viewable after upload in the form. Is there a setting somewhere I'm missing to fix this?

Thanks!

Formtastic 0.9.10 & Rails 2.3.8

Use of papermill tags with formtastic doesnt work as the papermill tags are not being returned from formtastic marked as HTML safe. Based on playing around with the papermill form builder it would appear that this is a formtastic issue.

Conflict with Facebox in DOM ID & Jquery Delete not working in form

  1. The facebox used an id = "footer" which can cause formatting problems when the plugin host app uses the same id in its layout - temporary solution - change the host app footer id so it is unique. more permanent solution provide the facebox footer with a unique id

  2. delete of images not working on the form (with or without Jquery no conflict) as a temporary hack have changed the javascript generated by the papermill asset form to us "J" instead of "$" and is now working

Papermill depends on mime-types >= 1.16

I'm preparing mime-types 2.0 for release, and it has some breaking API changes (not for most uses, but some esoteric features). The most important API change is that mime-types 2.0 no longer supports Ruby 1.8.

If this matters, the gemspec needs to be changed from >= 1.16 to ~> 1.16.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.