Commit 8fdf6ddf3b6731501c135a9f55d2c5ca18938d00

Authored by AntonioTerceiro
1 parent 28a4bf83

ActionItem154: cleaning up; modularizing the load_profile behaviour


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1255 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/application.rb
... ... @@ -53,12 +53,7 @@ class ApplicationController < ActionController::Base
53 53 def render_not_found(path = nil)
54 54 @path ||= request.path
55 55 # raise "#{@path} not found"
56   - render(:file => File.join(RAILS_ROOT, 'app', 'views', 'shared', 'not_found.rhtml'), :layout => 'not_found', :status => 404) && false
57   - end
58   -
59   - def load_profile
60   - @profile = Profile.find_by_identifier(params[:profile])
61   - render_not_found unless @profile
  56 + render(:file => File.join(RAILS_ROOT, 'app', 'views', 'shared', 'not_found.rhtml'), :layout => 'not_found', :status => 404) && fal
62 57 end
63 58  
64 59 def user
... ...
app/controllers/public/profile_controller.rb
1 1 class ProfileController < ApplicationController
  2 + needs_profile
2 3 end
... ...
app/helpers/application_helper.rb
... ... @@ -162,7 +162,7 @@ module ApplicationHelper
162 162 # should be a current profile (i.e. while viewing some profile's pages, or the
163 163 # profile info, etc), because if there is no profile an exception is thrown.
164 164 def profile
165   - @profile || raise("There is no current profile")
  165 + @controller.send(:profile) || raise("There is no current profile")
166 166 end
167 167  
168 168 # create a form field structure (as if it were generated with
... ...
lib/needs_profile.rb
... ... @@ -20,4 +20,9 @@ module NeedsProfile
20 20 @profile
21 21 end
22 22  
  23 + def load_profile
  24 + @profile = Profile.find_by_identifier(params[:profile])
  25 + render_not_found unless @profile
  26 + end
  27 +
23 28 end
... ...