undefined method insert_record for Array - ruby-on-rails-3

I have a Model A which has many objects of Model B using a :has_many association. When I create a new object of model A, set its attributes, build associated objects and inspect the non-persisted objects, it works fine. However, as soon as I try to persist the objects using save or save!, I am getting the following back-trace.
NoMethodError: undefined method `insert_record' for #<Array:0x000000052541f8>
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/associations/association_proxy.rb:154:in `send'
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/autosave_association.rb:306:in `block in save_collection_association'
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/associations/association_collection.rb:431:in `block in method_missing'
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/associations/association_proxy.rb:216:in `block in method_missing'
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/associations/association_proxy.rb:216:in `each'
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/associations/association_proxy.rb:216:in `method_missing'
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/associations/association_collection.rb:431:in `method_missing'
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/autosave_association.rb:297:in `save_collection_association'
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/autosave_association.rb:163:in `block in add_autosave_association_callbacks'
from /usr/lib/ruby/gems/2.0.0/gems/activesupport-3.0.5/lib/active_support/callbacks.rb:415:in `_run_create_callbacks'
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/callbacks.rb:281:in `create'
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/persistence.rb:246:in `create_or_update'
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/callbacks.rb:277:in `block in create_or_update'
from /usr/lib/ruby/gems/2.0.0/gems/activesupport-3.0.5/lib/active_support/callbacks.rb:418:in `_run_save_callbacks'
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/callbacks.rb:277:in `create_or_update'
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/persistence.rb:39:in `save'
... 2 levels...
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/transactions.rb:240:in `block (2 levels) in save'
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/transactions.rb:292:in `block in with_transaction_returning_status'
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/transactions.rb:207:in `transaction'
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/transactions.rb:290:in `with_transaction_returning_status'
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/transactions.rb:240:in `block in save'
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/transactions.rb:251:in `rollback_active_record_state!'
from /usr/lib/ruby/gems/2.0.0/gems/activerecord-3.0.5/lib/active_record/transactions.rb:239:in `save'
from (irb):104
from /usr/lib/ruby/gems/2.0.0/gems/railties-3.0.5/lib/rails/commands/console.rb:44:in `start'
from /usr/lib/ruby/gems/2.0.0/gems/railties-3.0.5/lib/rails/commands/console.rb:8:in `start'
from /usr/lib/ruby/gems/2.0.0/gems/railties-3.0.5/lib/rails/commands.rb:23:in `<top (required)>'
from /home/amitav/WMS/trunk/script/rails:6:in `require'
from /home/amitav/WMS/trunk/script/rails:6:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
I am using ruby 2.0.0p195 with rails 3.0.5.

This could be an compatibilityproblem. Update your Rails to a newer version v3.2 >=

Also if you don't want to upgrade your Rails 3.0.x project, make sure you run in on the ruby version where you developed it, e.g. 1.9.2 or 1.9.3.
With rvm or rbenv that should't be a problem.

Related

Rails 3: uninitialized constant IRB::ReadlineInputMethod::Readline (NameError) in Heroku

Ever since we updated to Rails 3.2.13 we've been unable to start the heroku rails console. The server is working just fine, but when we try to run the console, it gives the following error:
Loading production environment (Rails 3.2.13)
/app/vendor/bundle/ruby/1.9.1/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:212:in `const_missing_from_s3_library': uninitialized constant IRB::ReadlineInputMethod::Readline (NameError)
from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/irb/input-method.rb:113:in `gets'
from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/irb.rb:139:in `block (2 levels) in eval_input'
from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/irb.rb:273:in `signal_status'
from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/irb.rb:138:in `block in eval_input'
from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/irb/ruby-lex.rb:188:in `call'
from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/irb/ruby-lex.rb:188:in `buf_input'
from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/irb/ruby-lex.rb:103:in `getc'
from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/irb/slex.rb:205:in `match_io'
from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/irb/slex.rb:75:in `match'
from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/irb/ruby-lex.rb:286:in `token'
from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/irb/ruby-lex.rb:262:in `lex'
from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/irb/ruby-lex.rb:233:in `block (2 levels) in each_top_level_statement'
from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `loop'
from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `block in each_top_level_statement'
from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `catch'
from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `each_top_level_statement'
from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/irb.rb:155:in `eval_input'
from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/irb.rb:70:in `block in start'
from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/irb.rb:69:in `catch'
from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/irb.rb:69:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
What is going on? Thanks!
Just experienced this myself. As it turns out the rb-readline gem bumped a version that causes rails console, and other things to fail. Try locking it to '~> 0.4.2'.
gem 'rb-readline', '~> 0.4.2'

Unable to run the rails generator for Draper

I'm on Ruby 1.9.3 and Rails 3.0.11. I recently installed Draper(0.12.0) gem, but I'm unable to run its generators. I get the following error when I try to run the generator on the Post model :-
rails generate decorator Post
/home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.11/lib/active_support/whiny_nil.rb:48:in `method_missing': undefined method `config' for nil:NilClass (NoMethodError)
from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/draper-0.12.0/lib/draper/railtie.rb:6:in `block in <class:Railtie>'
from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/railtie.rb:189:in `call'
from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/railtie.rb:189:in `each'
from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/railtie.rb:189:in `load_generators'
from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/application.rb:147:in `block in load_generators'
from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/application/railties.rb:11:in `each'
from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/application/railties.rb:11:in `all'
from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/application.rb:147:in `load_generators'
from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/generators.rb:319:in `load_generators_from_railties!'
from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/generators.rb:278:in `lookup'
from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/generators.rb:141:in `find_by_namespace'
from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/generators.rb:161:in `invoke'
from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/commands/generate.rb:10:in `<top (required)>'
from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.11/lib/active_support/dependencies.rb:239:in `require'
from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.11/lib/active_support/dependencies.rb:239:in `block in require'
from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.11/lib/active_support/dependencies.rb:225:in `block in load_dependency'
from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.11/lib/active_support/dependencies.rb:593:in `new_constants_in'
from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.11/lib/active_support/dependencies.rb:225:in `load_dependency'
from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.11/lib/active_support/dependencies.rb:239:in `require'
from /home/mohnish/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.11/lib/rails/commands.rb:17:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Any inputs, on how can I debug this would be really helpful.
Thank you.
The Problem is this section in v0.12.0 (the one you are using) https://github.com/drapergem/draper/blob/v0.12.0/lib/draper/railtie.rb#L5-L8
When I look at the master branch they changed to code to look like: https://github.com/drapergem/draper/blob/master/lib/draper/railtie.rb#L5-L10
You should upgrade your draper gem to the latest release and see if the error still occurs.

devise generating views error

I've got a problem with devise gem, when I enter rails generate devise:install command there is an error:
/home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/inflector/methods.rb:124:in `block in constantize': unin
itialized constant View (NameError)
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/inflector/methods.rb:123:in `each'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/inflector/methods.rb:123:in `constantize'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/core_ext/string/inflections.rb:43:in `const
antize'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.1.rc1/lib/devise/mapping.rb:87:in `to'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.1.rc1/lib/devise/mapping.rb:80:in `modules'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.1.rc1/lib/devise/mapping.rb:93:in `strategies'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.1.rc1/lib/devise.rb:166:in `register'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.1.rc1/lib/devise/rails/routes.rb:92:in `block in devise_for'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.1.rc1/lib/devise/rails/routes.rb:91:in `each'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.1.rc1/lib/devise/rails/routes.rb:91:in `devise_for'
from /home/ofca/Praca/inzynierka/config/routes.rb:2:in `block in <top (required)>'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/routing/route_set.rb:258:in `instance_exec'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/routing/route_set.rb:258:in `eval_block'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/routing/route_set.rb:235:in `draw'
from /home/ofca/Praca/inzynierka/config/routes.rb:1:in `<top (required)>'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application/routes_reloader.rb:29:in `block in load_paths
'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application/routes_reloader.rb:29:in `each'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application/routes_reloader.rb:29:in `load_paths'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application/routes_reloader.rb:13:in `reload!'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application/routes_reloader.rb:7:in `block in initialize'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/file_update_checker.rb:32:in `call'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/file_update_checker.rb:32:in `execute_if_up
dated'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application/finisher.rb:63:in `block (2 levels) in <modul
e:Finisher>'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application/finisher.rb:64:in `call'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application/finisher.rb:64:in `block in <module:Finisher>
'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `instance_exec'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `run'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `each'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `run_initializers'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application.rb:96:in `initialize!'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/ofca/Praca/inzynierka/config/environment.rb:5:in `<top (required)>'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application.rb:83:in `require'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application.rb:83:in `require_environment!'
from /home/ofca/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/commands.rb:22:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I'm using Rails 3.1.1 and Ruby 1.9.2p290 (2011-07-09 revision 32553) on Linux. And db is postgres.
Here is the line mentioned in the first line of the error log:
constant = constant.const_defined?(name, false) ? constant.const_get(name) : constant.const_missing(name)
Oh, and I tried other combinations of this command: rails generate devise:install, rails g devise_install and it gives me the same effect
You are using a very old version of Devise that is not even meant to be used in production (it is a release candidate!). Please update your Devise version.
solution: add to gemfile:
gem 'devise', :git => 'git://github.com/plataformatec/devise.git'

Can't load 'firewatir' gem in rails 3

I want to run cucumber command in rails 3 controllers,but I add 'gem firewatir' to gemfile,
when I 'rails server', I got this error,and page shows "Internal Server Error".
[2011-03-24 14:32:05] INFO WEBrick 1.3.1
[2011-03-24 14:32:05] INFO ruby 1.8.7 (2009-06-12) [universal-darwin10.0]
[2011-03-24 14:32:05] INFO WEBrick::HTTPServer#start: pid=91734 port=3000
[2011-03-24 14:32:06] ERROR NoMethodError: undefined method `cache' for :active_support:Symbol
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.5/lib/active_support/cache/strategy/local_cache.rb:74:in `call'
/Library/Ruby/Gems/1.8/gems/rack-1.2.2/lib/rack/lock.rb:11:in `call'
/Library/Ruby/Gems/1.8/gems/rack-1.2.2/lib/rack/lock.rb:11:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rack-1.2.2/lib/rack/lock.rb:11:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-3.0.5/lib/action_dispatch/middleware/static.rb:30:in `call'
/Library/Ruby/Gems/1.8/gems/railties-3.0.5/lib/rails/application.rb:168:in `call'
/Library/Ruby/Gems/1.8/gems/railties-3.0.5/lib/rails/application.rb:77:in `send'
/Library/Ruby/Gems/1.8/gems/railties-3.0.5/lib/rails/application.rb:77:in `method_missing'
/Library/Ruby/Gems/1.8/gems/railties-3.0.5/lib/rails/rack/log_tailer.rb:14:in `call'
/Library/Ruby/Gems/1.8/gems/rack-1.2.2/lib/rack/content_length.rb:13:in `call'
/Library/Ruby/Gems/1.8/gems/rack-1.2.2/lib/rack/handler/webrick.rb:52:in `service'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/Library/Ruby/Gems/1.8/gems/rack-1.2.2/lib/rack/handler/webrick.rb:13:in `run'
/Library/Ruby/Gems/1.8/gems/rack-1.2.2/lib/rack/server.rb:213:in `start'
/Library/Ruby/Gems/1.8/gems/railties-3.0.5/lib/rails/commands/server.rb:65:in `start'
/Library/Ruby/Gems/1.8/gems/railties-3.0.5/lib/rails/commands.rb:30
/Library/Ruby/Gems/1.8/gems/railties-3.0.5/lib/rails/commands.rb:27:in `tap'
/Library/Ruby/Gems/1.8/gems/railties-3.0.5/lib/rails/commands.rb:27
script/rails:6:in `require'
script/rails:6
If I don't add 'gem firewatir' to gemfile, rails server can run,but when run the cucumber command, I get this error:
no such file to load -- firewatir (LoadError)
Anyone ever met this issue,or who know how to fix it? Thanks
I think it is a known (and fixed) problem: Watir and Rails 3.0.X incompatible
I'm not sure that this is the same thing since the stacktrace doesn't include any lines from commonwatir/firewatir. It could be something different, but can't say for sure.

Where do I put Sinatra files intended to be embedded in a Rails3 app?

I want to use the new Rails3 feature that allows you to embed a Sinatra app inside rails.
In my routes file, I have:
# app names changed to protect the (not so) innocent
MyApp::Application.routes.draw do
match "/service", :to => MyService
...
end
And in /lib/my_service.rb I have
class MyService < Sinatra::Base
get "/" do
"Hello World"
end
end
When I try to start the Rails server I get Uninitialized constant MyService (NameError), which I suspect means my Sinatra file is in the wrong directory. Where am I supposed to put it?
Full error text:
rails/my_app ยป rails server
=> Booting WEBrick
=> Rails 3.0.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/marshallyount/Projects/clients/method/rails/my_app/config/routes.rb:2:in `block in <top (required)>': uninitialized constant MyService (NameError)
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/actionpack-3.0.1/lib/action_dispatch/routing/route_set.rb:233:in `instance_exec'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/actionpack-3.0.1/lib/action_dispatch/routing/route_set.rb:233:in `draw'
from /Users/marshallyount/Projects/clients/method/rails/my_app/config/routes.rb:1:in `<top (required)>'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/railties-3.0.1/lib/rails/application.rb:127:in `block in reload_routes!'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/railties-3.0.1/lib/rails/application.rb:127:in `each'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/railties-3.0.1/lib/rails/application.rb:127:in `reload_routes!'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/railties-3.0.1/lib/rails/application.rb:120:in `block in routes_reloader'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/activesupport-3.0.1/lib/active_support/file_update_checker.rb:32:in `call'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/activesupport-3.0.1/lib/active_support/file_update_checker.rb:32:in `execute_if_updated'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/actionpack-3.0.1/lib/action_dispatch/railtie.rb:14:in `block (2 levels) in <class:Railtie>'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/activesupport-3.0.1/lib/active_support/callbacks.rb:419:in `_run_prepare_callbacks'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/actionpack-3.0.1/lib/action_dispatch/middleware/callbacks.rb:40:in `initialize'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/actionpack-3.0.1/lib/action_dispatch/middleware/stack.rb:33:in `new'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/actionpack-3.0.1/lib/action_dispatch/middleware/stack.rb:33:in `build'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/actionpack-3.0.1/lib/action_dispatch/middleware/stack.rb:79:in `block in build'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/actionpack-3.0.1/lib/action_dispatch/middleware/stack.rb:79:in `each'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/actionpack-3.0.1/lib/action_dispatch/middleware/stack.rb:79:in `inject'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/actionpack-3.0.1/lib/action_dispatch/middleware/stack.rb:79:in `build'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/railties-3.0.1/lib/rails/application.rb:162:in `app'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/railties-3.0.1/lib/rails/application/finisher.rb:35:in `block in <module:Finisher>'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/railties-3.0.1/lib/rails/initializable.rb:25:in `instance_exec'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/railties-3.0.1/lib/rails/initializable.rb:25:in `run'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/railties-3.0.1/lib/rails/initializable.rb:50:in `block in run_initializers'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/railties-3.0.1/lib/rails/initializable.rb:49:in `each'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/railties-3.0.1/lib/rails/initializable.rb:49:in `run_initializers'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/railties-3.0.1/lib/rails/application.rb:134:in `initialize!'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/railties-3.0.1/lib/rails/application.rb:77:in `method_missing'
from /Users/marshallyount/Projects/clients/method/rails/my_app/config/environment.rb:5:in `<top (required)>'
from /Users/marshallyount/Projects/clients/method/rails/my_app/config.ru:3:in `require'
from /Users/marshallyount/Projects/clients/method/rails/my_app/config.ru:3:in `block in <main>'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/rack-1.2.1/lib/rack/builder.rb:46:in `instance_eval'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/rack-1.2.1/lib/rack/builder.rb:46:in `initialize'
from /Users/marshallyount/Projects/clients/method/rails/my_app/config.ru:1:in `new'
from /Users/marshallyount/Projects/clients/method/rails/my_app/config.ru:1:in `<main>'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/rack-1.2.1/lib/rack/builder.rb:35:in `eval'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/rack-1.2.1/lib/rack/builder.rb:35:in `parse_file'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/rack-1.2.1/lib/rack/server.rb:162:in `app'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/rack-1.2.1/lib/rack/server.rb:248:in `wrapped_app'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/rack-1.2.1/lib/rack/server.rb:213:in `start'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/railties-3.0.1/lib/rails/commands/server.rb:65:in `start'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/railties-3.0.1/lib/rails/commands.rb:30:in `block in <top (required)>'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/railties-3.0.1/lib/rails/commands.rb:27:in `tap'
from /Users/marshallyount/.rvm/gems/ruby-1.9.2-p0#my_app/gems/railties-3.0.1/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I found a good answer for this question, thanks to this article.
I was missing the all important requires header at the top of my routes file:
require 'my_service.rb'
# app names changed to protect the (not so) innocent
MyApp::Application.routes.draw do
match "/service", :to => MyService
...
end