Topic: Rails on hosting server upgraded to 2.3.5 and my app broke

I wrote an RoR app about 1.5 years ago and hosted here since then:

http://www.hof-altgandersheim.net/ha/

Never changed the code. Rails was upgraded from 2.1.x to 2.3.5 some time ago on the server, and my app was broken since then.

The first page still loads, but any link on the menu bar no longer work.

For example, if one clicks the first link on the menu bar ( count from left ):

Der hof --> Restaurant & Cafe,

The URL will be:
http://hof-altgandersheim.net/ha/pages/1/display

The app says a 404 now, but such URLs used to work perfectly. Please note that the Please note that the "1" in the URL is not action id or session id but the category or page id stored in database.

The error log says:

Processing ApplicationController#index (for xxx.xxx.xxx.xxx at 2010-12-19 09:32:18) [GET]

ActionController::RoutingError (No route matches "//pages/1/display" with {:method=>:get}):

Rendering /home/hof/etc/rails_apps/ha/public/404.html (404 Not Found)   

hmmm.  I've never seen such error before, a bit lost.

Here is my route.rb:

ActionController::Routing::Routes.draw do |map|
  map.resources :users

  map.resources :notifications

  map.resources :pages, :member => {:display => :get, 
                                    :display_free_style => :get}

  map.resources :events, :collection => {:display => :get}

  map.resources :subcategories

  map.resources :categories  #, :has_many => :subcategories

  map.root :controller => "hof"

  
  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'
end

rake routes shows the following result:

 users GET    /users(.:format)                        {:action=>"index", :controller=>"users"}
                        POST   /users(.:format)                        {:action=>"create", :controller=>"users"}
               new_user GET    /users/new(.:format)                    {:action=>"new", :controller=>"users"}
              edit_user GET    /users/:id/edit(.:format)               {:action=>"edit", :controller=>"users"}
                   user GET    /users/:id(.:format)                    {:action=>"show", :controller=>"users"}
                        PUT    /users/:id(.:format)                    {:action=>"update", :controller=>"users"}
                        DELETE /users/:id(.:format)                    {:action=>"destroy", :controller=>"users"}
          notifications GET    /notifications(.:format)                {:action=>"index", :controller=>"notifications"}
                        POST   /notifications(.:format)                {:action=>"create", :controller=>"notifications"}
       new_notification GET    /notifications/new(.:format)            {:action=>"new", :controller=>"notifications"}
      edit_notification GET    /notifications/:id/edit(.:format)       {:action=>"edit", :controller=>"notifications"}
           notification GET    /notifications/:id(.:format)            {:action=>"show", :controller=>"notifications"}
                        PUT    /notifications/:id(.:format)            {:action=>"update", :controller=>"notifications"}
                        DELETE /notifications/:id(.:format)            {:action=>"destroy", :controller=>"notifications"}
                  pages GET    /pages(.:format)                        {:action=>"index", :controller=>"pages"}
                        POST   /pages(.:format)                        {:action=>"create", :controller=>"pages"}
               new_page GET    /pages/new(.:format)                    {:action=>"new", :controller=>"pages"}
              edit_page GET    /pages/:id/edit(.:format)               {:action=>"edit", :controller=>"pages"}
display_free_style_page GET    /pages/:id/display_free_style(.:format) {:action=>"display_free_style", :controller=>"pages"}
           display_page GET    /pages/:id/display(.:format)            {:action=>"display", :controller=>"pages"}
                   page GET    /pages/:id(.:format)                    {:action=>"show", :controller=>"pages"}
                        PUT    /pages/:id(.:format)                    {:action=>"update", :controller=>"pages"}
                        DELETE /pages/:id(.:format)                    {:action=>"destroy", :controller=>"pages"}
         display_events GET    /events/display(.:format)               {:action=>"display", :controller=>"events"}
                 events GET    /events(.:format)                       {:action=>"index", :controller=>"events"}
                        POST   /events(.:format)                       {:action=>"create", :controller=>"events"}
              new_event GET    /events/new(.:format)                   {:action=>"new", :controller=>"events"}
             edit_event GET    /events/:id/edit(.:format)              {:action=>"edit", :controller=>"events"}
                  event GET    /events/:id(.:format)                   {:action=>"show", :controller=>"events"}
                        PUT    /events/:id(.:format)                   {:action=>"update", :controller=>"events"}
                        DELETE /events/:id(.:format)                   {:action=>"destroy", :controller=>"events"}
          subcategories GET    /subcategories(.:format)                {:action=>"index", :controller=>"subcategories"}
                        POST   /subcategories(.:format)                {:action=>"create", :controller=>"subcategories"}
        new_subcategory GET    /subcategories/new(.:format)            {:action=>"new", :controller=>"subcategories"}
       edit_subcategory GET    /subcategories/:id/edit(.:format)       {:action=>"edit", :controller=>"subcategories"}
            subcategory GET    /subcategories/:id(.:format)            {:action=>"show", :controller=>"subcategories"}
                        PUT    /subcategories/:id(.:format)            {:action=>"update", :controller=>"subcategories"}
                        DELETE /subcategories/:id(.:format)            {:action=>"destroy", :controller=>"subcategories"}
             categories GET    /categories(.:format)                   {:action=>"index", :controller=>"categories"}
                        POST   /categories(.:format)                   {:action=>"create", :controller=>"categories"}
           new_category GET    /categories/new(.:format)               {:action=>"new", :controller=>"categories"}
          edit_category GET    /categories/:id/edit(.:format)          {:action=>"edit", :controller=>"categories"}
               category GET    /categories/:id(.:format)               {:action=>"show", :controller=>"categories"}
                        PUT    /categories/:id(.:format)               {:action=>"update", :controller=>"categories"}
                        DELETE /categories/:id(.:format)               {:action=>"destroy", :controller=>"categories"}
                   root        /                                       {:action=>"index", :controller=>"hof"}
                               /:controller/:id/:action                

here is the pages_controller.rb:

class PagesController < ApplicationController
  caches_page :display
  
  @@free_layout_pages = ["Demo Film", 
                         "Drive Instruction", "Legal & Credits",
                         "Business Time"]
  
  def index
    @pages = Page.find(:all, :order => "category_id")

    respond_to do |format|
      format.html 
      format.xml  { render :xml => @pages }
    end
  end

 
  def show
    @page = Page.find(params[:id])

    respond_to do |format|
      format.html 
      format.xml  { render :xml => @page }
    end
  end
  
  def display 
    @page = Page.find(params[:id])
    
    if (@@free_layout_pages.include?(@page.subcategory.name_en))
      redirect_to :action => "display_free_style"
    else
      respond_to do |format|
        format.html 
        format.xml  { render :xml => @page }
      end      
    end 
    
  end
  
  def display_free_style
    
    @page = Page.find(params[:id])
    
    respond_to do |format|
      format.html
      format.xml  { render :xml => @page }
    end      
  end

  def new
    @page = Page.new

    respond_to do |format|
      format.html 
      format.xml  { render :xml => @page }
    end
  end

  def edit
    @page = Page.find(params[:id])
  end

 
  def create
    @page = Page.new(params[:page])

    respond_to do |format|
      if @page.save
        flash[:notice] = 'Page was successfully created.'
        format.html { redirect_to(@page) }
        format.xml  { render :xml => @page, :status => :created, :location => @page }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @page.errors, :status => :unprocessable_entity }
      end
    end
  end

  
  def update
    @page = Page.find(params[:id])

    respond_to do |format|
      if @page.update_attributes(params[:page])
        flash[:notice] = 'Page was successfully updated.'
        format.html { redirect_to(@page) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @page.errors, :status => :unprocessable_entity }
      end
    end
  end

  def destroy
    @page = Page.find(params[:id])
    @page.destroy

    respond_to do |format|
      format.html { redirect_to(pages_url) }
      format.xml  { head :ok }
    end
  end
end

I just quickly read through the release notes of rails 2.3. But did not get any clue about what I should change to get my app running again. I must have missed something but don't know what.

Could anyone please give me a hint? Any help will be highly appreciated!



Best Regards,
Lydia

Last edited by lydia (2011-01-08 13:48:03)

Re: Rails on hosting server upgraded to 2.3.5 and my app broke

You should be able to find exactly what happened by looking at your log file.  Check the production.log file (if the current environment is production).  You should definitely see what the issue is.

Re: Rails on hosting server upgraded to 2.3.5 and my app broke

The problems you are seeing is the reason (IMHO) any real production application should be 'frozen' using rake rails:freeze:gems which results in your complete environment being copied into your application.  In this case it does not matter what version of rails is installed on the system or automaticly updated etc.   You can skip this if you have complete control and only update rails or gems after a comprehensive regression test.