相关疑难解决方法(0)

在Rails 3.1中有条理地将样式应用于回形针附件

我有以下型号:

Post.rb

  class Post < ActiveRecord::Base

  belongs_to :category
  has_many :attachments, :dependent => :destroy
  has_many :citations, :dependent => :destroy

  validates :title, :category_id, :content, :presence =>true

  acts_as_taggable_on :keywords
  accepts_nested_attributes_for :attachments, :allow_destroy => true, 
         :reject_if => proc { |attributes| attributes['photo'].blank?}
  accepts_nested_attributes_for :citations, :allow_destroy=>true

end
Run Code Online (Sandbox Code Playgroud)

Attachment.rb

  class Attachment < ActiveRecord::Base

  belongs_to :post

  has_attached_file :photo, :styles => { :medium => "637x471>", 
                :thumb => Proc.new { |instance| instance.resize },
                :carousel => Proc.new { |instance| instance.decide_style }
                },
                :url => "/pictures/:style/:basename.:extension",
                :path =>":rails_root/public/pictures/:style/:basename.:extension"


  validates_attachment_content_type :photo, :content_type => …
Run Code Online (Sandbox Code Playgroud)

forms ruby-on-rails paperclip

7
推荐指数
1
解决办法
2210
查看次数

标签 统计

forms ×1

paperclip ×1

ruby-on-rails ×1