Forum: Rails Engines development Noob help with routing

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Todd Nine (Guest)
on 2008-03-02 22:02
(Received via mailing list)
Hi all,
  I am trying to create my own plugin, and I'm not having much luck.  I
my structure set up with my controller, models and views.  I've been
able to
successfully migrate my database, however I can't get my routes to work.
have the following basic directory structure

+- project_ranking
    |  +-project_rank_controller.rb
    |  +-project_rank.rb
    |  +-order.rhtml

I'm trying to create a new route, and here is what I've defined in my
routes.rb file.

ActionController::Routing::Routes.draw do |map|

  connect 'projects/order', :controller => 'project_rank`', :action =>


Here is what I've added to the base project's routes.rb

 map.home '', :controller => 'welcome'

#my new routing
 map.from_plugin :project_ranking

### Other routes

However, when I try to load the default projects page (not a plugin).  I
receive the following routing errors

"no route found to match "/" with {:method=>:get}"

If I comment out my map.from_plugin, everything works fine again.

Any advice/help would be great.

James Adam (Guest)
on 2008-03-03 01:08
(Received via mailing list)
The routes.rb file in your plugin should only contain the inner
section of a normal application routes.rb file, I.e.

   connect '/path/:parameters', :controller => 'plugin_controller'

Note that it doesn't even contain the 'map'.


Todd Nine (Guest)
on 2008-03-03 04:55
(Received via mailing list)
Thanks James!  That fixed part of my problem.  I'm successfully getting
routes to work now.  However, it seems that my controller is never
and I'm now receiving a 404 error instead of the apps layout with
in the body as I expected.  The application I'm creating a plugin for is
redmine.  It uses site layouts and the standard "<%= yield %>" code for
body that is rendered from the called controller/action/view.  I simply
the following in my controller,and view, am I missing something else?  I
the order action to be called when the projects/order url is called.


connect 'projects/order', :controller => 'project_rank', :action =>


class ProjectRankController < ProjectsController
  def order
    print 'foobar';



Todd Nine (Guest)
on 2008-03-05 05:10
(Received via mailing list)
Well, just a follow up.  I fixed my issue by extending
"ApplicationController".  When I extend "ProjectsController" which is
of the base app, everything blows up.  Are we not allowed to extend code
from the base app in rails engine?

Cynthia Kiser (Guest)
on 2008-03-08 19:21
(Received via mailing list)
I think you could extend ProjectsController - but it would mean that
your ProjectRankController *is a* ProjectsController. So, for example,
I am not sure it would automatically know about your project_rank
model - it might just know about the project model.

Quoting Todd Nine <>:
Todd Nine (Guest)
on 2008-03-09 21:41
(Received via mailing list)
Hi Cynthia,
  I tried changing my controller to the following.

require_dependency "projects_controller"

class ProjectRankController < ProjectsController
  layout 'base'
  #require a manager to update priorities
  before_filter :require_manager, :only => :update
  before_filter :authorize, :except => :order



However when I try my overridden "list" action, it doesn't work with the
projects controller routes.  The default is "projects/list", but my list
action never gets called.  If my Project Rank Controller is a Project
controller, do I still have to change the routes to call my subclass?

This topic is locked and can not be replied to.