Inheritance problem with controllers


#1

i have a controller like this:

class SpoilageController < DataEntryController
before_filter { check_access_key(’_SP’) }

and in the parent class is this:

class DataEntryController < ApplicationController

def check_access_key(key)
if !@session[:user].admin &&
!@session[:user].data_entry_access.to_s.upcase.include?(key)
render :text=>‘You dont have access to this function’,
:layout=>true
false # disallow
end
end

But it crashes, with this error:
undefined method `check_access_key’ for SpoilageController:Class

Why can’t the spoilage class see the function in its parent class?
whats going on?


#2

chris wrote:

class SpoilageController < DataEntryController
before_filter { check_access_key(’_SP’) }

But it crashes, with this error:
undefined method `check_access_key’ for SpoilageController:Class

Try: before_filter { |controller| controller.check_access_key(’_SP’) }


We develop, watch us RoR, in numbers too big to ignore.


#3

Champion! worked.