Solved

Rails Console Error

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

751 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