paperclip

How to retrieve objects that have an attached file and order those objects based on a set of pre-ordered values?

别来无恙 提交于 2019-12-12 03:47:44
问题 I am using Ruby on Rails 3.2.2 and Paperclip 2.7.0. I would like to retrieve data from the database where records/objects have an attached file (in my case it is an image file) and order those objects based on a set of pre-ordered values. That is, I have image_file_name (handled by the Paperclip gem) and status (status can be published , unpublished , blocked ) database table columns and I would like that: returned data contains primarily records/objects to which is associated an image (maybe

Ruby/Paperclip: How to get missing.png to work? [duplicate]

你离开我真会死。 提交于 2019-12-12 03:18:37
问题 This question already has an answer here : Rails and Paperclip, default_url not working (1 answer) Closed 4 months ago . I am creating user avatars. I am having trouble getting the "missing.png" to show up. For users who decided not to upload a profile picture, I have created a default image to be displayed. Below is what I got so far. Please show me what I am doing wrong. user.rb has_attached_file :avatar, styles: { large: "800x800>", medium: "300x300>", thumb: "50x50>" }, default_url: "

Rails - Dokku - Paperclip: Every push to production breaks(404s) user uploaded images

走远了吗. 提交于 2019-12-12 03:16:53
问题 Running Rails 4 application on Digital Ocean with Dokku. Users can upload an image via paperclip. I can upload the images fine, and the application runs great and displays all images. Once I make a small change like a text change and I run $git push dokku master, all uploaded images 404. Model: class ProductImage < ActiveRecord::Base has_attached_file :image, default_url: "/images/:style/missing.png", :path =>":rails_root/public/system/:attachment/:id/:basename_:style.:extension", :url =>"

Paperclip dynamic styles based on polymorphic parent class doesn't work (Rails 4.2.5, Paperclip 4.3.1)

故事扮演 提交于 2019-12-12 02:56:18
问题 Basically I have an Image model which polymorphically belongs to imageable which are by far List and Item . Since an image will have its own attribute and relationship, I don't want to treat images like attributes of the List and Item and mess it up. So I create the Image model. What I want to achieve is that List should have a logo thumb image where height equals width but Item has a different style. Paperclip doc has told us to create dynamic styles using lambda . So here's my Image model:

How to use helper method in environment configuration?

ⅰ亾dé卋堺 提交于 2019-12-12 02:52:23
问题 I have the following helper method in application_controller.rb : class ApplicationController < ActionController::Base def current_tenant @current_tenant ||= Tenant.find_by(domain: Apartment::Tenant.current) end helper_method :current_tenant end The tenant table also stores some information that I want to use in the environment configuration like so (this is development.rb ): Rails.application.configure do config.paperclip_defaults = { :s3_credentials => { :bucket => current_tenant.amazon_s3

error with multiple image upload

家住魔仙堡 提交于 2019-12-12 02:28:12
问题 Iam new to rails 4 i want add multiple images.i have a product model and picture model in my app.product has many picture and picture has a image and its a paperclip attachment but i cant access images in my view models/products.rb class Product < ActiveRecord::Base belongs_to :user belongs_to :category has_many :comments , dependent: :destroy has_many :pictures, :dependent => :destroy end models/picture.rb class Picture < ActiveRecord::Base belongs_to :product accepts_nested_attributes_for

Rails 4: Paperclip Error Post model missing required attr_accessor for 'image_file_name'

跟風遠走 提交于 2019-12-12 02:28:00
问题 First, let me specify that I did find two questions on Stack Overflow that are very similar to my problem: Model missing required attr_accessor for 'image_file_name' - Ruby on Rails 4 Paperclip Error: model missing required attr_accessor for 'avatar_file_name' However, I am not sure the issue is the same. Let me explain. In my Rails 4 app, I have the following models: class User < ActiveRecord::Base has_many :administrations has_many :calendars, through: :administrations end class Calendar <

Heroku- Could not find paperclip-3.1.3 in any of the sources

a 夏天 提交于 2019-12-12 02:08:51
问题 This morning when I tried to update my website, heroku didn't let me push the app. Here's the message I got. Fetching gem metadata from http://rubygems.org/....... Fetching gem metadata from http://rubygems.org/.. Fetching git://github.com/drhenner/nifty-generators.git Could not find paperclip-3.1.3 in any of the sources ! ! Failed to install gems via Bundler. ! ! Heroku push rejected, failed to compile Ruby/rails app ! [remote rejected] master -> master (pre-receive hook declined) I don't

Rails paperclip img upload error: “no file chosen” with rmagick installed

…衆ロ難τιáo~ 提交于 2019-12-12 02:07:37
问题 I can't get to upload images using paperclip. Whenever I choose the file and submit the page reloads and says "no file chosen". My code trip.rb class Trip < ActiveRecord::Base has_many :images accepts_nested_attributes_for :images, :allow_destroy => true attr_accessible :messages_attributes end The form <%= f.fields_for :images do |image_fields| %> <% if image_fields.object.new_record? %> <%= image_fields.file_field :image %> <% end %> <% end %> Image.rb class Image < ActiveRecord::Base

saving multiple images using accept_nested_attributes using paperclip in rails 3

坚强是说给别人听的谎言 提交于 2019-12-12 02:07:22
问题 i have two models ########## image.rb has_many :image_assets , :dependent => :destroy accepts_nested_attributes_for :image_assets, :reject_if => lambda { |a| a[:avatar].blank? }, :allow_destroy => true ########## image_assets.rb belongs_to :image has_attached_file :avatar, :styles => {:view => "187x260#"}, :storage => :s3, :s3_permissions => :private, :s3_credentials => S3_CREDENTIALS attr_accessible :image_id,:avatar,:avatar_file_name,:avatar_content_type,:avatar_file_size,:avatar_updated_at