Undefined method error for 'join_table_name' #42

d2kagw opened this Issue Nov 10, 2011 · 19 comments


None yet
10 participants

d2kagw commented Nov 10, 2011

When creating a new project (using Rails 3.1) and doing the most basic of setups, you run into these errors.
You're able to work around it by explicitly supplying the join_table_name option with every acts_as_... call, but that's not ideal.

Here's the code i've used to work around:
acts_as_authorization_object subject_class_name: "User", join_table_name: "roles_users"


be9 commented Nov 10, 2011

Well, I'm sorry but acl9 doesn't support Rails 3.1 officially. I guess the method for join table name generation was removed in 3.1.

erwin16 commented Nov 13, 2011

same error ... too bad ! Rails 3.1 is there to stay ...
any suggestion for equivalent gem ?


EnriqueVidal commented Nov 17, 2011

I'd be glad to try my luck adding 3.1 support, however I couldn't find documentation on how to run acl9 tests, this is clearly related to #40, if anyone can point me in the right direction on how to run the gem's tests I'll be more than happy to collaborate.

I try use acl9 with Rails 3.2 and got same error. I create small patch and it's work well for me:
File: acl9/model_extensions.rb

  def acts_as_authorization_role(options = {})
    subject = options[:subject_class_name] || Acl9::config[:default_subject_class_name]
    join_table = options[:join_table_name] || Acl9::config[:default_join_table_name] ||
                 self.table_name_prefix + [undecorated_table_name(self.to_s), undecorated_table_name(role)].sort.join("_") + self.table_name_suffix
                 # comment out use deprecated API
                 #join_table_name(undecorated_table_name(self.to_s), undecorated_table_name(subject))

    has_and_belongs_to_many subject.demodulize.tableize.to_sym,
      :class_name => subject,
      :join_table => join_table

    belongs_to :authorizable, :polymorphic => true

I test it and all is OK for me. Could you please fix it in the master branch? Thanks


d2kagw commented Jan 28, 2012

Oooh, looks awesome.
Will give it a stab later today

TobiG77 commented Feb 29, 2012

The fix from adederer works, as long as you do:

acts_as_authorization_role :subject_class_name => 'User'

Otherwise you get error #48

@be9 be9 added a commit that referenced this issue Feb 29, 2012

@be9 be9 Merge pull request #49 from TobiG77/master
Addressed bug #42 and #48

I still get this error. I thought the above fix was merged or have I misunderstood?

Rails 3.2 I still need to use:

acts_as_authorization_subject :join_table_name => 'roles_users'

p.s Thanks for all your time on this. Loving your work!


EnriqueVidal commented Apr 22, 2012

@shaunbrazier I have multiple upgrades in mind for acl9 one of them is to ensure full rails 3.2 integration, I'll be looking into that in the following days, thanks for reporting bugs.

That's great news.

Another issue I've just run into, and this time I'm stumped:

1.9.2-p290 :008 > u.has_role! "admin"
Role Load (0.2ms) SELECT "roles".* FROM "roles" WHERE (name = 'admin' and authorizable_type IS NULL and authorizable_id IS NULL) LIMIT 1
(0.1ms) begin transaction
SQL (20.5ms) INSERT INTO "roles" ("authorizable_id", "authorizable_type", "created_at", "name", "updated_at") VALUES (?, ?, ?, ?, ?) ["authorizable_id", nil], ["authorizable_type", nil], ["created_at", Mon, 23 Apr 2012 01:41:44 UTC +00:00], ["name", "admin"], ["updated_at", Mon, 23 Apr 2012 01:41:44 UTC +00:00] commit transaction
SystemStackError: stack level too deep
from /Users/me/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/workspace.rb:80
Maybe IRB bug!!
1.9.2-p290 :009 > u.roles
=> []


be9 commented Apr 23, 2012

@EnriqueVidal I've added you as a collaborator on the repo. Frankly speaking, I don't have time to support acl9, neither I use it in my current projects. Feel free to push good code directly :)

@olegdashevskii what do you use if not acl9 - just out of interest...

On 23/04/2012, at 2:33 PM, Oleg Dashevskii wrote:

@EnriqueVidal I've added you as a collaborator on the repo. Frankly speaking, I don't have time to support acl9, neither I use it in my current projects. Feel free to push good code directly :)

Reply to this email directly or view it on GitHub:
#42 (comment)


be9 commented Apr 23, 2012

I use cancan. It's mostly simple rulesets without any specific per-object permissions.


EnriqueVidal commented Apr 23, 2012

Thanks @be9 I've been updating acl9 as frequently as possible, my next commits should be in a week or so and thanks for the fine work you've been doing.

drewda commented May 15, 2012

Is it possible to use this patched version of acl9 now? I see that the version on rubygems.org is quite old. But if I instead try to point my gemfile to the Github repo, it complains because the gemspec still requires Rails 2.3.12. Bundler complains when I try to install it in my Rails 3.2.3 app. Any suggestions on how to proceed?


EnriqueVidal commented May 16, 2012

You can use the one in rubygems on 3.2 check #66 for more info, I have created a new milestone with the aim of testing entirely in 3.2.

drewda commented May 17, 2012

Thank you for the quick response, @EnriqueVidal.

Turns out I just had to whitelist some of the attributes on Roles for mass assignment, as Rails 3.2.3 now makes that a requirement.

I'll look forward to seeing your updates to bring acl9 more fully into Rails 3.x land!

manxingxing referenced this issue in befdata/befdata Jan 17, 2013


Make Acl9 work as before #166

Sorry, I didn't know the link will create a reference here. I am still new to RoR, making acl9 work with rails3.2 is a little difficult for me.

@jhuckabee jhuckabee pushed a commit to jhuckabee/acl9 that referenced this issue Jan 9, 2014

Tobias Gerschner incorporate fix suggested from: be9#42
	modified:   lib/acl9/model_extensions.rb

@jhuckabee jhuckabee pushed a commit to jhuckabee/acl9 that referenced this issue Jan 9, 2014

@matadon matadon Fixed be9#42 for acts_as_authorization_object 8d0a89b

smathy commented Nov 20, 2014

This is fixed in HEAD.

smathy closed this Nov 20, 2014

smathy added the bug label Nov 20, 2014

smathy added this to the 1.0 - Rails 4 milestone Nov 20, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment