Commit 8690de542ab6a195fcc4426bb91b8ad059e988ab

Authored by Leandro Nunes dos Santos
1 parent 83fd2007

refactoring set_homepage method

Showing 1 changed file with 7 additions and 10 deletions   Show diff stats
app/controllers/my_profile/cms_controller.rb
... ... @@ -142,20 +142,17 @@ class CmsController < MyProfileController
142 142 render :action => 'edit'
143 143 end
144 144  
145   - def home_page
146   - profile.home_page
147   - end
148   -
149 145 post_only :set_home_page
150 146 def set_home_page
151   - @article = params[:id] != nil ? profile.articles.find(params[:id]) : nil
152   - profile.home_page = @article
153   - profile.save(false)
154   - if @article != nil
155   - session[:notice] = _('"%s" configured as home page.') % @article.name
156   - else
  147 + article = params[:id].nil? ? nil : profile.articles.find(params[:id])
  148 + profile.update_attribute(:home_page, article)
  149 +
  150 + if @article.nil?
157 151 session[:notice] = _('home page reseted.')
  152 + else
  153 + session[:notice] = _('"%s" configured as home page.') % article.name
158 154 end
  155 +
159 156 redirect_to (request.referer || profile.url)
160 157 end
161 158  
... ...