Solved

Rails Console Error

Posted on 2011-02-14
1
745 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

623 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