Solved

Rails Console Error

Posted on 2011-02-14
1
739 Views
Last Modified: 2012-05-11
Why does this happen? Its a new project and I am new to ruby.
irb(main):018:0> ActionController::Routing::Routes.draw 
NoMethodError: undefined method `arity' for nil:NilClass
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-3.0.4/lib/active_support/whiny_nil.rb:48:in `method_missing'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-3.0.4/lib/action_dispatch/routing/route_set.rb:230:in `draw'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-3.0.4/lib/active_support/deprecation/proxy_wrappers.rb:24:in `method_missing'
	from (irb):18
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/railties-3.0.4/lib/rails/commands/console.rb:44:in `start'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/railties-3.0.4/lib/rails/commands/console.rb:8:in `start'
	from /opt/local/lib/ruby1.9/gems/1.9.1/gems/railties-3.0.4/lib/rails/commands.rb:23:in `<top (required)>'
	from script/rails:6:in `require'
	from script/rails:6:in `<main>'
irb(main):019:0>

Open in new window


I am trying to do:
puts ActionController::Routing::Routes.draw do |map|
	map.resources :users
end.map(&:to_s).sort

Open in new window


But I keep getting the above error. I am using Rails 3 on OSX.
0
Comment
Question by:LinuxInAtlanta
1 Comment
 
LVL 4

Accepted Solution

by:
kristinalim earned 500 total points
ID: 34991840
If you're trying to print out method names for an isolated set of routes, this should get you started:

route_set = ActionDispatch::Routing::RouteSet.new
route_set.draw { |map| map.resources :users }

# Unique names, without the _url nor _path
puts route_set.routes.map(&:name).uniq.compact.sort

Open in new window

0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Choosing a Server-Side Scripting Language - Criterion 5 5 295
Ruby on Rails website showing twice 3 285
ruby error while running a java class from ruby 1 521
TextArea Parameter 1 223
I recently rediscovered rails when I needed a holiday project and decided to build a management dashboard for the company where I work.  With it being a project done in my free time, I could focus my time on learning the basics rather than trying to…
Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question