refile

refile simple_form undefined method attachment_field

北战南征 提交于 2019-12-07 08:49:02
问题 I am trying to hook up refile to my view and I am getting the following error: Here are my models: class Job < ActiveRecord::Base acts_as_paranoid acts_as_taggable acts_as_taggable_on :languages belongs_to :company belongs_to :category validates :title, :location, :category, :language_list, :short_description, :description, :application_process, presence: true end class Company < ActiveRecord::Base acts_as_paranoid has_many :jobs attachment :company_logo, type: :image validates :name, :url,

Get image dimensions using Refile

有些话、适合烂在心里 提交于 2019-12-06 01:42:58
问题 Using the Refile gem to handle file uploading in Rails, what is the best way to determine image height and width during / after it has been uploaded? There is no built in support for this AFAIK, and I can't figure out how to do it using MiniMagick. 回答1: @russellb's comment almost got me there, but wasn't quite correct. If you have a Refile::File called @file, you need to: fileIO = @file.to_io.to_io mm = MiniMagick::Image.open(fileIO) mm.width # image width mm.height # image height Yes, that's

Get image dimensions using Refile

拈花ヽ惹草 提交于 2019-12-04 05:53:11
Using the Refile gem to handle file uploading in Rails, what is the best way to determine image height and width during / after it has been uploaded? There is no built in support for this AFAIK, and I can't figure out how to do it using MiniMagick. Mike V @russellb's comment almost got me there, but wasn't quite correct. If you have a Refile::File called @file, you need to: fileIO = @file.to_io.to_io mm = MiniMagick::Image.open(fileIO) mm.width # image width mm.height # image height Yes, that's two calls to #to_io >...< The first to_io gives you a Tempfile, which isn't what MiniMagick wants.