Commit cd5d929a42b8c53cecc3059b3aeb0bd06a4dd18a

Authored by Marcos Pereira
1 parent 560f0b22

Refactors article initialize method

Showing 1 changed file with 4 additions and 8 deletions   Show diff stats
app/models/article.rb
@@ -28,17 +28,13 @@ class Article < ActiveRecord::Base @@ -28,17 +28,13 @@ class Article < ActiveRecord::Base
28 28
29 def initialize(*params) 29 def initialize(*params)
30 super 30 super
31 -  
32 if params.present? && params.first.present? 31 if params.present? && params.first.present?
33 - if params.first.has_key?(:profile) && !params.first[:profile].blank?  
34 - profile = params.first[:profile]  
35 - self.published = false unless profile.public_profile 32 + if params.first.symbolize_keys.has_key?(:published)
  33 + self.published = params.first.symbolize_keys[:published]
  34 + elsif params.first[:profile].present? && !params.first[:profile].public_profile
  35 + self.published = false
36 end 36 end
37 -  
38 - self.published = params.first["published"] if params.first.has_key?("published")  
39 - self.published = params.first[:published] if params.first.has_key?(:published)  
40 end 37 end
41 -  
42 end 38 end
43 39
44 def self.default_search_display 40 def self.default_search_display