This project is archived and is in readonly mode.
Rails 3.0.3 Controller inheritance is broken
Reported by jamesw | May 15th, 2011 @ 03:10 PM
I'm just starting a new app and I'm using Rails 3.0.3
I have the typical admin and customer name spaces with no namespace
for all public areas and I have a typical OO approach for my
controllers as follows
In their most basic form the controllers look like this
class ApplicationController < ActionController::Base
before_filter :authorize, :except => :login
end
class PublicController < ApplicationController
protected #Protected methods available to all descendant controllers
#This is a public controller so no authorization is necessary def authorize end
#Other methods that need to be made available for public controllers to be added here ... end
class CustonerController < ApplicationController
protected #Protected methods available to all descendant controllers
#This is a customer controller so authorize as a customer #TODO def authorize end
#Other methods that need to be made available for public controllers to be added here #TODO def current_customer end ... end
And again similarly for the admin controller
class AdminController < ApplicationController
protected #Protected methods available to all descendant controllers
#This is a customer controller so authorize as a customer #TODO def authorize end
#Other methods that need to be made available for public controllers to be added here #TODO def current_customer end ... end
My first admin controller, which is a section for customer
maintenance, ath the moment is a standard scaffolded controller
with the following exceptions
redirect_to and :location paths/declarations take into account the
namespace for admin e.g. redirect_to admin_customers_path
plus the important class declaration and the relevant changes have
been made to the views to take into account the admin namespace
class Admin::CustomerController < AdminController
Controller for customer administration
... end
Now if I navigate to myapp/admin/users I would expect to see a
list of all users but instead I get an error
Started GET "/api/users" for 127.0.0.1 at Sun May 15 15:04:44 +0100
2011
AbstractController::ActionNotFound (The action 'show' could not
be found for AdminController):
Rendered /home/jamie/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/unknown_action.erb within rescues/layout (0.5ms)
This works fine in Rails 2.3.5 -> 2.3.8 not tested under
other 2.3.x versions.
there is very obviously a fundamental change in the way controller
classes behave differently to normal OO rules in Rails 3.0.3 and I
have to ask what is going on? and will there/is there a fix for
this?
Cheers
James
Comments and changes to this ticket
-
jamesw May 15th, 2011 @ 03:27 PM
Sorry for the unformatted code
This is the code formatted (hopefully easier to read (That'll teach me not to hit the preview button)
@@@ class ApplicationController < ActionController::Base before_filter :authorize, :except => :loginend
class PublicController < ApplicationController
protected
#Protected methods available to all descendant controllers
#This is a public controller so no authorization is necessary def authorize end
#Other methods that need to be made available for public controllers to be added here ... end
class CustonerController < ApplicationController
protected #Protected methods available to all descendant controllers
#This is a customer controller so authorize as a customer #TODO def authorize end
#Other methods that need to be made available for public controllers to be added here #TODO def current_customer end ... end
And again similarly for the admin controller
class AdminController < ApplicationController
protected #Protected methods available to all descendant controllers
#This is a customer controller so authorize as a customer #TODO def authorize end
#Other methods that need to be made available for public controllers to be added here #TODO def current_customer end ... end @@@
And
@@@ class Admin::CustomerController < AdminController #Controller for customer administration
#... end @@@
-
jamesw May 15th, 2011 @ 03:28 PM
Oh well! Formatting still isn't right please feel free to delete the above comment and this one
-
jamesw May 15th, 2011 @ 05:07 PM
Further investigation shows the same issue on Rails 3.0.7 but I'm unable to test on 3.1 beta1 as I am unable to get 3.1 beta1 apps to run (I'm getting an error with bundle and sqlite gem errors)
-
jamesw May 15th, 2011 @ 08:15 PM
Sorry, My mistake.
I had a corrupted routes.rb file.
A totally new project did not have this problem.
Please close this ticket
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>