Commit cd5d929a42b8c53cecc3059b3aeb0bd06a4dd18a
1 parent
560f0b22
Exists in
web_steps_improvements
and in
7 other branches
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 | 28 | |
29 | 29 | def initialize(*params) |
30 | 30 | super |
31 | - | |
32 | 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 | 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 | 37 | end |
41 | - | |
42 | 38 | end |
43 | 39 | |
44 | 40 | def self.default_search_display | ... | ... |