Created
August 30, 2011 21:55
-
-
Save thedelchop/1182190 to your computer and use it in GitHub Desktop.
Unorganized code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class News < ActiveRecord::Base | |
acts_as_commentable | |
cattr_reader :per_page | |
@@per_page = 7 | |
belongs_to :user | |
has_many :posts, :as => :posting, :dependent => :destroy | |
has_attached_file :image, | |
:styles => { | |
:large => "400x400>", | |
:large_headline => "400x225#", | |
:medium_headline => "250x195#", | |
:thumb => "50x50#" | |
}, | |
:storage => :s3, | |
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml", | |
:path => ":attachment/:id/:style.:extension" | |
default_scope order("created_at desc") | |
scope :with_images, where("image_file_name IS NOT NULL") | |
has_many :_endorsements, :as => :item, :class_name => 'Endorsement' | |
def body_html | |
RedCloth.new(self.body).to_html.gsub(/<\/?del>/,' - ') | |
end | |
def followers | |
self.user.followers | |
end | |
def commenters | |
self.comments.map {|comment| comment.user }.uniq #=> ["a!", "b!", "c!", "d!"] | |
end | |
# emits_pfeeds :on => [:create] , :for => [ :participant_only ] # also available – :itself, :all_in_its_class | |
# receives_pfeed | |
validates_presence_of :title, :body, :summary | |
validates_length_of :summary, :maximum => 200 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment