views:

227

answers:

2

I've just installed railroad and tried to run a couple simple example runs. I have an application model and controller that are causing it some heartburn.

There is no real application table - the model is used to load (include) things like the authenication system. The controller sets up the helper_methods, etc.

I also have many controllers which are in a subdir admin for many of the models.

when I run: railroad -o models.dot -M I get: /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1833:in method_missing': undefined method helper_method' for Application(Table doesn't exist):Class (NoMethodError)

when I run: railroad -o controllers.dot -C I get /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in `load_missing_constant': uninitialized constant CoverageAmountsController (NameError)

the coverage_amounts.rb controller (class Admin::CoverageAmountsController < AdminController) is in app/controllers/admin - if I move it out it gives this on the next controller in the admin directory - so it appears to not like controllers in the admin folder.

What can I do to resolve these issues? Is there something I can do within railroad or my app to make it work? I'd like to use something like this to see if it will work for my needs.

Thanks...

A: 

Don't use application as the name for a model, as this leads to confusion with the application controller - also named application.rb. See this thread in the rails wiki: http://wiki.rubyonrails.org/rails/pages/ReservedWords#fn2

Note this issue should be resolved in edge rails: http://github.com/rails/rails/commit/fcce1f17eaf9993b0210fe8e2a8117b61a1f0f69

Also ActiveRecord assumes that you have a corresponding table for your class (I think). You probably want to include the authentication system into the application controller, unless you have a good reason not to.

You might find that making this change fixes the other controller issues you were having. Let me know either way.

A: 

Thanks for the reply...

I've got a few things happening in the application model. Can these all be moved over to the application controller and give the same results?

class Application < ActiveRecord::Base

  include AuthenticatedSystem
  # this gives all model access to current_user
  before_filter { |c| User.current_user = c.current_user }

  # some miscellanous modules
  require HashExtensions
  require LiquidExtensions

end
Streamline