stffn / declarative_authorization

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

Railtie and Engine for Rails 3 #44

Open stffn opened 14 years ago

stffn commented 14 years ago

According to e.g. https://gist.github.com/e139fa787aa882c0aa9c we need to subclass Engine to enable the registration of the authorization development backend when decl_auth is integrated as gem in Rails 3.

One approach is in 1ab1422f02c85f9334e8e3ea443887f6127ddfff

Which other features of Engine/Railtie should we be using? Register config hooks?

mjonuschat commented 14 years ago

I haven't looked into all the configuration options available in DA yet, but from the top of my head I would see these two options on the top of the list

1) Get initializer to run under Rails3. I don't mind if it's done the way HAML 2.2.x does it with an init_rails method getting called from vendor/plugins/haml or by subclassing Engine. If it's going to be done the vendor/plugins way, generators for Rails2 and Rails3 should be added to DA.

2) Add a config hook for the authorization rules file(s). I think it would be much cleaner than setting constants early on in the rails boot process.

stffn commented 14 years ago

On (1): not sure, how my environment can be different from yours, but in my case I don't need the explicit railtie to have decl_auth working as a gem in Rails 3. Anyway, I pushed your commit. Hopefully, this helps.

mjonuschat commented 14 years ago

Thank you, works as charm now with the "official" version. I don't know what's different either, but I can consistently reproduce it on three machines just using Rails3 + DA, no other Gems involved.

I'll try it on a different OS just for fun, as all test machines are Macs.

tovodeverett commented 11 years ago

I worked around this by adding the following to my config/initializers/application.rb file:

module Authorization
  AUTH_DSL_FILES.replace([Pathname.new(Rails.root || '').join("config", "authorization_rules.rb").to_s])
end