Changeset d615d174087ec3b764e19b0799273741a6c8dee6
- Timestamp:
- 07/27/10 23:10:33 (6 weeks ago)
- Author:
- Alban Peignier <alban@…>
- Parents:
- acff4dc3eee6e062cc1a86e06e6fd6fba910ee78
- git-committer:
- Alban Peignier <alban@tryphon.eu> / 2010-07-27T23:10:33Z+0200
- Message:
-
Fix PublicController#welcome? loop when Show isn't found. Refs #14
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
rc5037a4
|
rd615d17
|
|
| 7 | 7 | append_view_path "#{Rails.root}/templates" |
| 8 | 8 | |
| 9 | | before_filter :assigns_show, :create_user_google_analytics_account, :except => [:feed, :robots] |
| | 9 | before_filter :assigns_show, :create_user_google_analytics_account, :except => [:feed, :robots, :welcome] |
| 10 | 10 | before_filter :assigns_now |
| 11 | 11 | |
| … |
… |
|
| 13 | 13 | |
| 14 | 14 | def welcome |
| 15 | | if @show.blank? |
| | 15 | begin |
| | 16 | load_show |
| | 17 | render_show |
| | 18 | rescue ActiveRecord::RecordNotFound |
| 16 | 19 | # localhost is used in development |
| 17 | 20 | # www.example.com is used by cucumber |
| 18 | | if request.host =~ /(www.)bonnes-ondes\.fr|bonnes-ondes\.local|localhost|www.example.com/ |
| 19 | | @episodes_last = Episode.find(:all, :order => "created_at DESC", :limit => 10) |
| | 21 | if request.host =~ /www.bonnes-ondes\.fr|www.bonnes-ondes\.local|localhost|www.example.com/ |
| | 22 | @episodes_last = Episode.find :all, :order => "created_at DESC", :limit => 10 |
| 20 | 23 | else |
| 21 | 24 | raise ActiveRecord::RecordNotFound |
| 22 | 25 | end |
| 23 | | else |
| 24 | | render_show |
| 25 | 26 | end |
| 26 | 27 | end |
| … |
… |
|
| 92 | 93 | |
| 93 | 94 | def show_home_page_when_not_found |
| | 95 | logger.info "Page not found for #{request.host}#{request.path}" |
| 94 | 96 | flash[:notice] = "La page demandée n'existe pas" |
| 95 | | redirect_to "/" |
| | 97 | unless request.path == "/" |
| | 98 | redirect_to "/" |
| | 99 | else |
| | 100 | redirect_to "http://www.bonnes-ondes.fr" |
| | 101 | end |
| 96 | 102 | end |
| 97 | 103 | |
| … |
… |
|
| 118 | 124 | request.google_analytics_account = Rubaidh::GoogleAnalytics.new(user_tracker_id) |
| 119 | 125 | end |
| | 126 | rescue ActiveRecord::RecordNotFound |
| | 127 | logger.debug "Can't find an associated Show for Goggle Analytics account" |
| 120 | 128 | end |
| 121 | 129 | |