stffn / declarative_authorization

An unmaintained authorization plugin for Rails. Please fork to support current versions of Rails
MIT License
1.24k stars 233 forks source link

undefined method `shift' for :authorization_rules:Symbol #185

Closed psjavi closed 10 years ago

psjavi commented 11 years ago

Hi, when I try to execute http://localhost:3000/authorization_rules I've got the error:

"undefined method `shift' for :authorization_rules:Symbol"

NoMethodError - undefined method shift' for :authorization_rules:Symbol: declarative_authorization (0.5.7) lib/declarative_authorization/development_support/analyzer.rb:212:inprocess_call'

I'm using Rails 4.0.0 and Ruby 1.9.3

daniel-rikowski commented 11 years ago

It looks like the sexps generated by the ruby_parser gem are not in the expected format.

psjavi commented 11 years ago

Hi, I've been debugging a little and these are the values ​​that have been taking from line 210 to line 212:

value of exp

exp = s(s(:hash, s(:lit, :to), s(:lit, :manage)))

arglist_line = exp[0].line

arglist_line = 14

arglist = process(exp.shift).shift

arglist = :array

context = arglist.shift

NoMethodError: undefined method `shift' for :array:Symbol

What's the expected format?

Thanks!!

zeiv commented 10 years ago

I'm not sure how, but it looks like the DSL analyzer was acting up, which is strange because the authorization rules I had in my Rails 4 app were working fine for me. As far as I can tell this issue was not exclusive to Rails 4 though since there were a lot tests failing or with errors even when I ran the test suite in Rails 3.2 on ruby 1.9.3 and Rails 2.3 on 1.8.7. Everything seems to be working after the above commits though.

markmilman commented 9 years ago

@stffn, is this fixed as part of the latest published gem? (doesn't seem like it as per rubygems 0.5.7 is the latest version which was published before this was fixed).

Thanks