Undefined local variable or method `current_user' for


#1

Hi All, I am using a Plugin mdarby-restful_acl with
restful_authentication and I am following the procedure form
http://github.com/mdarby/restful_acl/tree/master , but I am getting some
irritating error “undefined local variable or method `current_user’
for”, I
know I am missing something but I dont know what?
Can anybody help me regarding this?

Shahroon


#2

Hi,

generally plugins require methods like current_user implemented in
application.rb for integration purposes.
This method should return an object of the user

NAYAK

On Fri, Jan 9, 2009 at 6:33 PM, shahroon ali removed_email_address@domain.invalid
wrote:

  • NAYAK

#3

Okay, but could you please explain it in detail, I mean what I have to
define in application.rb and how to define? And whats the whole
procedure?
Thanks in advance
Shahroon


#4

that depends on your plugin. did you follow all the instructions in
README? what’s your complete error-trace? where does the error occurr?


#5

undefined local variable or method `current_user’ for
#OpportunityController:0x3c8d02c

vendor/plugins/mdarby-restful_acl/lib/restful_acl.rb:11:in
`has_permission?’

C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:469:in
send!' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:469:incall’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:441:in
run' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:716:inrun_before_filters’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:695:in
call_filters' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:689:inperform_action_without_benchmark’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in
perform_action_without_rescue' C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:inmeasure’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in
perform_action_without_rescue' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/rescue.rb:199:inperform_action_without_caching’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:678:in
perform_action' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:33:incache’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/query_cache.rb:8:in
cache' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:677:inperform_action’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in
send' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:inprocess_without_filters’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:685:in
process_without_session_management_support' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/session_management.rb:123:inprocess’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:388:in
process' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:171:inhandle_request’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in
dispatch' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:indispatch_cgi’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in
dispatch' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel/rails.rb:76:inprocess’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel/rails.rb:74:in
synchronize' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel/rails.rb:74:inprocess’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:159:in
process_client' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:158:ineach’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:158:in
process_client' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:285:inrun’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:285:in
initialize' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:285:innew’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:285:in
run' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:268:ininitialize’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:268:in
new' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:268:inrun’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel/configurator.rb:282:in
run' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel/configurator.rb:281:ineach’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel/configurator.rb:281:in
run' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/mongrel_rails:128:inrun’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel/command.rb:212:in
run' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/mongrel_rails:281 C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:inload’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in
load' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:innew_constants_in’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in
load' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/mongrel.rb:64 C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require’
C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
require' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:inrequire’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in
new_constants_in' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:inrequire’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39
C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire’
script/server:3

When I tried to add this row

In environment.rb:

config.gem “mdarby-restful_acl”, :lib => ‘restful_acl’

in my environment.rb file it stopped my server. After commenting this
line I got the above mentioned error. I am getting this when ever I
put this line in my controller

before_filter :has_permission?

And this is really disturbing.

Thanks again,

Shahroon


#6

another one:
did you install the restful_athentication plugin first?
http://techno-weenie.net/2006/8/1/restful-authentication-plugin

even if you installed the “mdarby-restful_acl” gem or plugin you’ll
need the restful_authentication-plugin anyways.


#7

No problem at all, in fact you are helping me a lot.Well I have
installed
my gem “mdarby-restful_acl” and its installation was completed
successfully.
And I have downloaded the auhthentication_acl as well and I think its
installation had some problems and I just put that whole plugin directly
into my vendor/plugin folder.
Shahroon


#8

And I have downloaded the auhthentication_acl as well and I think its
installation had some problems and I just put that whole plugin directly
into my vendor/plugin folder.

what do you mean by “some problems”? the current_user-functionality is
provided by “restful_authentication”-plugin. if there are unsolved
problems, you should absolutely take care of them.
here is the latest version:
http://github.com/technoweenie/restful-authentication/tree/master/README.textile#INSTALL


#9

it’s always hard to guess, what could be the problem in other people’s
code, so excuse me for asking:
did you install the gem “mdarby-restful_acl”? (= does it show up on
“gem list”?)

In environment.rb:

config.gem “mdarby-restful_acl”, :lib => ‘restful_acl’


#10

shahroon ali wrote:

Yeah I checked it was installed properly, there was no error in
installing
it, i was just mistaken.

I wrote RESTful_ACL; are you using restful_authentication (like followed
their directions), or did you just install it a plugin?

This error indicates that you’re not actually using
restful_authentication


#11

Yeah I checked it was installed properly, there was no error in
installing
it, i was just mistaken.


#12

He’s missing include AuthenticatedSystem from application.rb

Ryan B.
Freelancer
http://frozenplague.net


#13

Thanks everyone, you helped me a lot in solving my problem. Now
restful_authentication is working fine but restful_acl isn’t, I am
following
the instructions written here
http://github.com/mdarby/restful_acl/tree/master but when ever i add
this
line of code

config.gem “mdarby-restful_acl”, :lib => ‘restful_acl’

in my environment.rb file my server doesn’t start. And whenever I
comment
this line and then restart my server it works but the controller with
has_permission? doesn’t work. It takes me to denied page.
Please help me in solving this issue.
Thanks & Regards,
Shahroon


#14

It has been solved, everything is fine and working now. Once again
thanks
everyone.
Thanks & Regards,

Shahroon


#15

do you have any console output, error message, log entry or whatsoever?