netzke / netzke-core

Framework for Sencha Ext JS + Ruby on Rails client-server components
http://netzke.org
Other
263 stars 77 forks source link

Make parent controller configurable #59

Closed jhaagmans closed 11 years ago

jhaagmans commented 11 years ago

As we discussed, I'd like the parent controller to be configurable so that I can, for instance, use my AdminController as my parent controller. I've made a suggestion.

I'm not entirely happy with the change in the NetzkeController. I wanted to add a @@parent_controller_class declaration to Netzke::Core, but Netzke::Core doesn't seem to know about the ApplicationController class. So this is my suggestion.

Tests pass. I considered adding a ParentController inheriting from ApplicationController to the test app and configuring that in the netzke initializer, but that felt like overdoing it.

Cheers!

mxgrn commented 11 years ago

Did this work for you? I tried specifying my custom controller in the initialisers, but at the moment of evaluating netzke_controller.b, Netzke::Core.parent_controller_class is still nil, so, ApplicationController is always used.

mxgrn commented 11 years ago

I'm experimenting with routes instead. My idea is to allow specifying multiple Netzke routes in config/routes.rb, each of which would map to its own controller (that will have to be inherited from NetzkeController). What do you think? I'll post here when I have something.

jhaagmans commented 11 years ago

Hmmm, I may have overlooked something, but I did have it working in my test application somehow. I'll report back tomorrow.

Your routing solution sounds like it might work for my use case, but you would have to make the NetzkeController inherit from ActionController::Base by default and that might pose a problem for people who are relying on NetzkeController inheriting from ApplicationController (instead of the other way around).

mxgrn commented 11 years ago

you would have to make the NetzkeController inherit from ActionController::Base by default

Why ActionController::Base? I don't see why it can't be inherited from ApplicationController as it is now.

jhaagmans commented 11 years ago

Well, you're absolutely right. This is not working. I have overlooked the fact that the NetzkeController class is defined before running the initializers. I had only tested the functionality locally and saw the tests go green because there was nothing wrong with the syntax itself. I'll leave this open to discuss how to proceed, I might also have an idea I'll share as soon as it's clear how I want to do it.

jhaagmans commented 11 years ago

And why not ApplicationController: because in my use case it wouldn't work. I could work around it of course (and will if this is the way to go), but that would mean my ApplicationController would be there for the sole purpose of being a parent controller to my NetzkeController. Our frontend requires user authentication (and doesn't use Netzke) and our backend requires admin authentication.

I'll think about this some more.

mxgrn commented 11 years ago

I got your point about ApplicationController.

I'm closing this one before we get something working.