Note that there are some explanatory texts on larger screens.

plurals
  1. POPaperclip not saving attachment on Padrino
    text
    copied!<p>I am building a site using padrino. I use paperclip for uploading logos to one of the models. The problem I am experiencing is that Paperclip does not save the attachment, but also does not throw any errors. I think that the parameters passed to the controller are of incorrect type, as the <code>params[:logo]</code> is a hash and should probably be a some kind of a file type? How can I make Paperclip save the attachments passed in the parameters?</p> <p>The model:</p> <pre><code>class Charity &lt; ActiveRecord::Base include Paperclip::Glue attr_accessible :name, :description, :logo has_attached_file :logo, path: "/public/:attachment/:id/:basename.:extension" end </code></pre> <p>The logo is set in the controller like so:</p> <pre><code>post :create do @charity = Charity.new(params[:charity]) if @charity.save! flash[:notice] = 'Charity was successfully created.' redirect url(:charities, :edit, id: @charity.id) else render 'charities/new' end end </code></pre> <p>The form passing the parameters to the controller looks like this (parts omitted for brevity):</p> <pre><code>- form_for :charity, url(:charities, :create), multipart: true, class: :form do |f| (...) .group ==f.label :logo ==f.error_message_on :logo ==f.file_field :logo (...) </code></pre> <p>I am using Paperclip 2.7.0 and Padrino 0.10.7. I also have added this to boot.rb as per <a href="https://stackoverflow.com/questions/8612139/using-paperclip-with-padrino">Using Paperclip with Padrino</a> :</p> <pre><code>Padrino.before_load do File.send(:include, Paperclip::Upfile) Paperclip.options[:logger] = Padrino.logger Paperclip.options[:command_path] = "/usr/local/bin" ActiveRecord::ConnectionAdapters::AbstractAdapter.send(:include, Paperclip::Schema) ActiveRecord::ConnectionAdapters::Table.send(:include, Paperclip::Schema) ActiveRecord::ConnectionAdapters::TableDefinition.send(:include, Paperclip::Schema) end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload