Class: Article
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Article
- Defined in:
- app/models/article.rb
Constant Summary collapse
- @@per_page =
10
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.give_user_status_symbol(user, status) ⇒ Object
46 47 48 |
# File 'app/models/article.rb', line 46 def self.give_user_status_symbol(user, status) "user#{user[:id]}_status#{status}".to_sym end |
Instance Method Details
#remove_illegal_characters ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'app/models/article.rb', line 66 def remove_illegal_characters ugly_characters = "\x00-\x1F" exchange_character = ' ' .tr!(ugly_characters, exchange_character) unless .nil? title.tr!(ugly_characters, exchange_character) unless title.nil? summary.tr!(ugly_characters, exchange_character) unless summary.nil? body.tr!(ugly_characters, exchange_character) unless body.nil? url.tr!(ugly_characters, '') unless url.nil? end |
#set_user_status(user, status) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/models/article.rb', line 54 def set_user_status(user, status) article_status = ArticleStatus.find_by_user_id_and_article_id_and_status(user, self, status) if article_status.nil? article_status = ArticleStatus.new article_status.user = user article_status.article = self article_status.status = status article_status.save! end self.touch end |
#size ⇒ Object
50 51 52 |
# File 'app/models/article.rb', line 50 def size title.size + summary.size + body.size + url.size end |