This project is archived and is in readonly mode.

#4511 ✓resolved
Mario Olivio Flores

ActionView::PathSet .exists? fails due to nil array

Reported by Mario Olivio Flores | April 30th, 2010 @ 02:52 PM

This method fails: http://github.com/rails/rails/blob/master/actionpack/lib/action_vie...

Due to the error evaluating an empty array: "occurred while evaluating nil.empty?"

The empty array is here: http://github.com/rails/rails/blob/master/actionpack/lib/action_vie...

seems like "unless prefix.empty?" should be just "unless prefix"

Comments and changes to this ticket

  • Tanel Suurhans

    Tanel Suurhans April 30th, 2010 @ 10:39 PM

    Probably needs a bit more information to write a failing test-case. The fix in itself looks easy enough.

  • Ryan Bigg

    Ryan Bigg May 25th, 2010 @ 09:58 AM

    • State changed from “new” to “open”

    Please provide a way to duplicate this method failure.

  • Mario Olivio Flores

    Mario Olivio Flores June 14th, 2010 @ 02:23 AM

    You could submit any value to view_paths.exists? and it will fail.

    Here is my example. I am using a pages_controller, to manage my static pages. Before attempting to load a template, I want my app to ensure the template exists, using a before filter.

    class PagesController < ApplicationController
      unloadable
      before_filter :ensure_valid
    
      def show
        render :template => current_page
      end
    
      protected
    
      def ensure_valid
        unless view_paths.exists?(current_page)
          render :nothing => true, :status => 404 and return false
        end
      end
    
      def current_page
        "pages/#{params[:id].to_s.downcase}"
      end
    end
    
  • José Valim

    José Valim June 22nd, 2010 @ 04:24 PM

    • State changed from “open” to “resolved”

    Fixed on master.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages