Solved

Rails Console Error

Posted on 2011-02-14
1
735 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Article by: narshlob
If you've ever programmed in Ruby and have come across either a proc or a lambda, you might have been wondering what the difference is between the two and when you would use one over the other. This article will try to explain the difference between…
In Ruby, Call or invoke a API DLL library is easily via Win32API class, win32-api gem or other gems. For general DLL API call, there are quite a few references, some good tips list below: http://www.rubytips.org/2008/05/13/accessing-windows-api-fro…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now