Sha256: d96c10cdf2dc1f5617569c96ef9406d02dd42de4212960e4669fcaf023981f12

Contents?: true

Size: 1.19 KB

Versions: 7

Compression:

Stored size: 1.19 KB

Contents

module Fuel
  class Author < ActiveRecord::Base

    has_many :posts

    if Rails.version[0].to_i < 4
      attr_accessible :first_name, :last_name, :title, :bio, :avatar, :email, :twitter, :github, :dribbble, :start_date
    end

    def full_name
      [first_name, last_name].compact.join(" ")
    end

    if Fuel.configuration.aws_bucket
      has_attached_file :avatar, :styles => { :medium => Fuel.configuration.avatar_settings[:styles][:medium], :thumb => Fuel.configuration.avatar_settings[:styles][:thumb] }, :default_url => "fuel/default-img.jpg", :storage => :s3, :s3_credentials => Proc.new{|a| a.instance.s3_credentials }
    else
      has_attached_file :avatar, :styles => { :medium => Fuel.configuration.avatar_settings[:styles][:medium], :thumb => Fuel.configuration.avatar_settings[:styles][:thumb] }, :default_url => "fuel/default-img.jpg"
    end

    validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/
    validates :first_name, :last_name, :title, presence: true

    def s3_credentials
      {:bucket => Fuel.configuration.aws_bucket, :access_key_id => Fuel.configuration.aws_access_key, :secret_access_key => Fuel.configuration.aws_secret_access_key}
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fuel-0.4.1 app/models/fuel/author.rb
fuel-0.3.34 app/models/fuel/author.rb
fuel-0.3.33 app/models/fuel/author.rb
fuel-0.3.32 app/models/fuel/author.rb
fuel-0.3.31 app/models/fuel/author.rb
fuel-0.3.30 app/models/fuel/author.rb
fuel-0.3.29 app/models/fuel/author.rb