Radio, Web and Free Software

Changeset d615d174087ec3b764e19b0799273741a6c8dee6

Show
Ignore:
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:
1 modified

Legend:

Unmodified
Added
Removed
  • app/controllers/public_controller.rb

    rc5037a4 rd615d17  
    77  append_view_path "#{Rails.root}/templates" 
    88 
    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] 
    1010  before_filter :assigns_now 
    1111 
     
    1313 
    1414  def welcome 
    15     if @show.blank? 
     15    begin 
     16      load_show 
     17      render_show 
     18    rescue ActiveRecord::RecordNotFound 
    1619      # localhost is used in development 
    1720      # 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 
    2023      else 
    2124        raise ActiveRecord::RecordNotFound 
    2225      end 
    23     else 
    24       render_show 
    2526    end 
    2627  end 
     
    9293 
    9394  def show_home_page_when_not_found 
     95    logger.info "Page not found for #{request.host}#{request.path}" 
    9496    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 
    96102  end 
    97103 
     
    118124      request.google_analytics_account = Rubaidh::GoogleAnalytics.new(user_tracker_id) 
    119125    end 
     126  rescue ActiveRecord::RecordNotFound 
     127    logger.debug "Can't find an associated Show for Goggle Analytics account" 
    120128  end 
    121129