CanCan błąd: uninitialized constant

Witam, tym razem mam problem z zastosowaniem CanCana. Zgodnie z railscastem zainstalowałęm gem i stworzyłem model Ability.

#models/ability.rb

[code]class Ability
include CanCan::Ability

def initialize(user)
user ||= User.new # guest user (not logged in)
if user.role == “admin”
can :manage, Post
else
can [:new,:index,:show,:create], Post
end
end
end[/code]
Sprawdzać uprawnienia chcę w controlerze postów:

[code]class PostsController < ApplicationController

before_filter :require_user, :only => [ :new ]
load_and_authorize_resource
…[/code]
W chwili gdy wchodzę na localhost/posts/

Dostaję błąd:

[quote]NameError in PostsController#index
uninitialized constant ActiveRecord::Relation

vendor/rails/activesupport/lib/active_support/dependencies.rb:442:in load_missing_constant' vendor/rails/activesupport/lib/active_support/dependencies.rb:77:inconst_missing’
/var/lib/gems/1.8/gems/cancan-1.6.0/lib/cancan/model_adapters/active_record_adapter.rb:102:in override_scope' vendor/rails/activerecord/lib/active_record/attribute_methods.rb:211:inany?’
/var/lib/gems/1.8/gems/cancan-1.6.0/lib/cancan/model_adapters/active_record_adapter.rb:102:in each' /var/lib/gems/1.8/gems/cancan-1.6.0/lib/cancan/model_adapters/active_record_adapter.rb:102:inany?’
/var/lib/gems/1.8/gems/cancan-1.6.0/lib/cancan/model_adapters/active_record_adapter.rb:102:in override_scope' /var/lib/gems/1.8/gems/cancan-1.6.0/lib/cancan/model_adapters/active_record_adapter.rb:89:indatabase_records’
/var/lib/gems/1.8/gems/cancan-1.6.0/lib/cancan/model_additions.rb:23:in accessible_by' /var/lib/gems/1.8/gems/cancan-1.6.0/lib/cancan/controller_resource.rb:81:inload_collection’
/var/lib/gems/1.8/gems/cancan-1.6.0/lib/cancan/controller_resource.rb:34:in load_resource' /var/lib/gems/1.8/gems/cancan-1.6.0/lib/cancan/controller_resource.rb:25:inload_and_authorize_resource’
/var/lib/gems/1.8/gems/cancan-1.6.0/lib/cancan/controller_resource.rb:10:in send' /var/lib/gems/1.8/gems/cancan-1.6.0/lib/cancan/controller_resource.rb:10 vendor/rails/activesupport/lib/active_support/callbacks.rb:182:incall’
vendor/rails/activesupport/lib/active_support/callbacks.rb:182:in evaluate_method' vendor/rails/activesupport/lib/active_support/callbacks.rb:166:incall’
vendor/rails/actionpack/lib/action_controller/filters.rb:225:in call' vendor/rails/actionpack/lib/action_controller/filters.rb:629:inrun_before_filters’
vendor/rails/actionpack/lib/action_controller/filters.rb:615:in call_filters' vendor/rails/actionpack/lib/action_controller/filters.rb:610:inperform_action_without_benchmark’
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in perform_action_without_rescue' /usr/lib/ruby/1.8/benchmark.rb:293:inmeasure’
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in perform_action_without_rescue' vendor/rails/actionpack/lib/action_controller/rescue.rb:136:inperform_action_without_caching’
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in perform_action' vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:34:incache’
vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in cache' vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:inperform_action’
vendor/rails/actionpack/lib/action_controller/base.rb:524:in send' vendor/rails/actionpack/lib/action_controller/base.rb:524:inprocess_without_filters’
vendor/rails/actionpack/lib/action_controller/filters.rb:606:in process_without_session_management_support' vendor/rails/actionpack/lib/action_controller/session_management.rb:134:inprocess’
vendor/rails/actionpack/lib/action_controller/base.rb:392:in process' vendor/rails/actionpack/lib/action_controller/dispatcher.rb:184:inhandle_request’
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:112:in dispatch_unlocked' vendor/rails/actionpack/lib/action_controller/dispatcher.rb:125:indispatch’
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:124:in synchronize' vendor/rails/actionpack/lib/action_controller/dispatcher.rb:124:indispatch’
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:134:in dispatch_cgi' vendor/rails/actionpack/lib/action_controller/dispatcher.rb:41:indispatch’
/home/chmarus/.gem/ruby/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in process' /home/chmarus/.gem/ruby/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:insynchronize’
/home/chmarus/.gem/ruby/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in process' /home/chmarus/.gem/ruby/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:inprocess_client’
/home/chmarus/.gem/ruby/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in each' /home/chmarus/.gem/ruby/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:inprocess_client’
/home/chmarus/.gem/ruby/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in run' /home/chmarus/.gem/ruby/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:ininitialize’
/home/chmarus/.gem/ruby/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in new' /home/chmarus/.gem/ruby/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:inrun’
/home/chmarus/.gem/ruby/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in initialize' /home/chmarus/.gem/ruby/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:innew’
/home/chmarus/.gem/ruby/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in run' /home/chmarus/.gem/ruby/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:inrun’
/home/chmarus/.gem/ruby/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in each' /home/chmarus/.gem/ruby/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:inrun’
/home/chmarus/.gem/ruby/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in run' /home/chmarus/.gem/ruby/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:inrun’
/home/chmarus/.gem/ruby/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
vendor/rails/activesupport/lib/active_support/dependencies.rb:142:in load_without_new_constant_marking' vendor/rails/activesupport/lib/active_support/dependencies.rb:142:inload’
vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in new_constants_in' vendor/rails/activesupport/lib/active_support/dependencies.rb:142:inload’
vendor/rails/railties/lib/commands/servers/mongrel.rb:64
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require' /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:inrequire’
vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in require' vendor/rails/activesupport/lib/active_support/dependencies.rb:521:innew_constants_in’
vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in require' vendor/rails/railties/lib/commands/server.rb:49 /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require’
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require’
script/server:3[/quote]
Cóż to może być?

Próbowałeś zabawy z różnymi wersjami gemów?

Wrzuć może wynik polecenia:

gem list --local

ten błąd jest po przejściu z 1.4 na 1.6, może też innych, nagraj sobie gem w wersji 1.4 i powinno być ok, chyba

No i load_and_auth… z tego co pamiętam chyba musi być na samej górze, jako pierwszy wpis, ale nie wiem czy to jeszcze istotne.