Ok. So now I've namespace my ApplicationController like so:
class Citygate::Admin::ApplicationController < ::Admin::ApplicationController
protect_from_forgery
layout 'admin/application'
rescue_from CanCan::AccessDenied do |exception|
redirect_to root_url, :alert => exception.message
end
end
The problem here is that I want the app/admin/application_controller.rb to be
able to change the cancan redirect and since the engine's controller inherits
from it, the engine's definitions will always take precendence. This is not the
functionality I want. I want to be able to provide some defaults in the engine
that can be overidden in the app.
Am I doing anything wrong here?
On May 23, 2012, at 11:49 PM, Ryan Bigg wrote:
> Indeed, the application's app/controllers/application_controller.rb will take
> precedence over a similarly named file in the engine. The same goes for
> anything else in the app directory, too.
>
> This is why you namespace your engine: to avoid collisions such as these.
> On Thursday, 24 May 2012 at 4:46 AM, Luís Ferreira wrote:
>
>> Hi,
>>
>> I've been using rails 3 engines and (at least in my experience) the engine's
>> application controller is overidden by the app's application controller.
>> Wouldn't it be better if the app would just load on top of the engine?
>>
>> I mean that if an engine's application controller has methods or anything
>> else that does not collide with the stuff defined with the app, couldn't it
>> be used?
>>
>> Isn't this the default behaviour of ruby, that you can just reopen a class
>> and add methods to it possibly overriding them but not deleting the rest of
>> the class?
>>
>>
>> Regards,
>> Luís Ferreira
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ruby on Rails: Core" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/rubyonrails-core?hl=en.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-core?hl=en.
Cumprimentos,
Luís Ferreira
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en.