NoMethodError in undefined method `scoped' in rails (using ancestry gem) - ruby-on-rails

I am using the ancestry gem and i m testing my model in the console first.When i use
root = Message.create(:content => "hello")
It inserts data into the database but when i use
child = root.children.create(:content => "hhjjh")
It gives an error.This is the log
NoMethodError: undefined method `scoped' for #<Class:0x007fa4a61182b0>
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/activerecord-4.1.8/lib/active_record/dynamic_matchers.rb:26:in `method_missing'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/ancestry-1.2.3/lib/ancestry/instance_methods.rb:136:in `children'
from (irb):2
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/railties-4.1.8/lib/rails/commands/console.rb:90:in `start'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/railties-4.1.8/lib/rails/commands/console.rb:9:in `start'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:69:in `console'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/railties-4.1.8/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `block in require'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'
from /Users/zeeshandar/chat/bin/rails:8:in `<top (required)>'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:241:in `load'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:241:in `block in load'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:241:in `load'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/spring-1.2.0/lib/spring/commands/rails.rb:6:in `call'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/spring-1.2.0/lib/spring/command_wrapper.rb:38:in `call'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/spring-1.2.0/lib/spring/application.rb:183:in `block in serve'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/spring-1.2.0/lib/spring/application.rb:156:in `fork'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/spring-1.2.0/lib/spring/application.rb:156:in `serve'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/spring-1.2.0/lib/spring/application.rb:131:in `block in run'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/spring-1.2.0/lib/spring/application.rb:125:in `loop'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/spring-1.2.0/lib/spring/application.rb:125:in `run'
from /Users/zeeshandar/.rvm/gems/ruby-2.1.5/gems/spring-1.2.0/lib/spring/application/boot.rb:18:in `<top (required)>'
from /Users/zeeshandar/.rbenv/versions/2.1.3/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/zeeshandar/.rbenv/versions/2.1.3/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
I don't know what i m doing wrong but i think this is suppose to work.Any ideas?

It looks like your version of Ancestry is 1.2.3 or something. Updating to a new version looks like it should fix that problem.
Gemfile
gem 'ancestry', '~> 2.1'

Related

Rails Generate command error

I am using Rails version 4.2.7.1 and ruby 2.2.5 with rvm.
After bundle update I cannot run rails g command anymore.
The following error keeps appearing:
-- [](4.2)
/Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:664:in `block in method_missing': undefined method `[]' for #<ActiveRecord::Migration:0x007fce8f996460> (NoMethodError)
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:634:in `block in say_with_time'
from /Users/Sergei/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/benchmark.rb:288:in `measure'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:634:in `say_with_time'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:654:in `method_missing'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:416:in `method_missing'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/encrypted_store-0.3.0/lib/generators/encrypted_store/upgrade/ZeroOneFive/templates/upgrade_encryption_keys_to_015.rb:1:in `<top (required)>'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in `require'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in `block in require'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in `require'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/encrypted_store-0.3.0/lib/encrypted_store/railtie.rb:18:in `block (2 levels) in <class:Railtie>'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/encrypted_store-0.3.0/lib/encrypted_store/railtie.rb:18:in `each'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/encrypted_store-0.3.0/lib/encrypted_store/railtie.rb:18:in `block in <class:Railtie>'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/railties-4.2.7.1/lib/rails/railtie.rb:228:in `call'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/railties-4.2.7.1/lib/rails/railtie.rb:228:in `block in run_generators_blocks'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/railties-4.2.7.1/lib/rails/railtie.rb:245:in `each'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/railties-4.2.7.1/lib/rails/railtie.rb:245:in `each_registered_block'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/railties-4.2.7.1/lib/rails/railtie.rb:228:in `run_generators_blocks'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/railties-4.2.7.1/lib/rails/application.rb:462:in `block in run_generators_blocks'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/railties-4.2.7.1/lib/rails/engine/railties.rb:13:in `each'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/railties-4.2.7.1/lib/rails/engine/railties.rb:13:in `each'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/railties-4.2.7.1/lib/rails/application.rb:462:in `run_generators_blocks'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/railties-4.2.7.1/lib/rails/engine.rb:461:in `load_generators'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/railties-4.2.7.1/lib/rails/commands/commands_tasks.rb:129:in `generate_or_destroy'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/railties-4.2.7.1/lib/rails/commands/commands_tasks.rb:50:in `generate'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/railties-4.2.7.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/railties-4.2.7.1/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
Already tried reinstalling gemset and deleting all previous migration files, but it did not help. What could be the reason?
OK! I solved by myself. As I could see from this line
from /Users/Sergei/.rvm/gems/ruby-2.2.5#rails4/gems/encrypted_store-0.3.0/lib/generators/encrypted_store/upgrade/ZeroOneFive/templates/upgrade_encryption_keys_to_015.rb:1:in `<top (required)>'
It had dependency from gem encrypted_store. I removed this gem from Gemfile and reinstalled in with bundle command (gem 'encrypted_store', '~> 0.2.8'). After this the error was gone.

I have issues starting the server

I am new to the ruby environment. I configured ruby and when I start the server I am hit with the series of errors. Can someone please give me a hand please.
2.3.1 :001 > rails s
NameError: undefined local variable or method `s' for main:Object
from (irb):1
from /Users/User/.rvm/gems/ruby-2.3.1/gems/railties-4.2.6/lib/rails/commands/console.rb:110:in `start'
from /Users/User/.rvm/gems/ruby-2.3.1/gems/railties-4.2.6/lib/rails/commands/console.rb:9:in `start'
from /Users/User/.rvm/gems/ruby-2.3.1/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/User/.rvm/gems/ruby-2.3.1/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/User/.rvm/gems/ruby-2.3.1/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/User/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
from /Users/User/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
from /Users/User/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/User/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
from /Users/User/workspace/dineconnect-backend/bin/rails:9:in `<top (required)>'
from /Users/User/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
from /Users/User/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `block in load'
from /Users/User/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/User/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
from /Users/User/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/commands/rails.rb:6:in `call'
from /Users/User/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/command_wrapper.rb:38:in `call'
from /Users/User/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application.rb:191:in `block in serve'
from /Users/User/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application.rb:161:in `fork'
from /Users/User/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application.rb:161:in `serve'
from /Users/User/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application.rb:131:in `block in run'
from /Users/User/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application.rb:125:in `loop'
from /Users/User/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application.rb:125:in `run'
from /Users/User/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application/boot.rb:19:in `<top (required)>'
from /Users/User/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/User/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
You are trying to start rails server in interactive Ruby Shell (IRB or irb), or may be rails console.
use the command
rails s
in your terminal
You should have to look into this http://guides.rubyonrails.org/getting_started.html for the rails basics.
You are using rails console. Get out of the console by typing quit and then type rails s

Is there something wrong with this Rails Console error message?

Very new to Rails, so bear with me -
Currently paranoid that my ruby and gem versions aren't up to date because I'd occasionally get error messages when running rails test. Previously had rvm and rbenv both installed, but wow I've removed both and reinstalled rvm only.
When I go into a irb and call an action that doesn't work, such as: "foo".select, I get a simple error message:
NoMethodError: private method 'select' called for "foo":String
from (irb):4
from /Users/Joseph/.rvm/rubies/ruby-2.3.1/bin/irb:11:in '<main>'
However, when I type the same command "foo".select in rails console instead, I get:
NoMethodError: private method `select' called for "foo":String
from (irb):1
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/railties-5.0.0.1/lib/rails/commands/console.rb:65:in `start'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/railties-5.0.0.1/lib/rails/commands/console_helper.rb:9:in `start'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:78:in `console'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from /Users/Joseph/workspace/sample_app/bin/rails:9:in `<top (required)>'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `block in load'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/spring-1.7.2/lib/spring/commands/rails.rb:6:in `call'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/spring-1.7.2/lib/spring/command_wrapper.rb:38:in `call'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/spring-1.7.2/lib/spring/application.rb:191:in `block in serve'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/spring-1.7.2/lib/spring/application.rb:161:in `fork'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/spring-1.7.2/lib/spring/application.rb:161:in `serve'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/spring-1.7.2/lib/spring/application.rb:131:in `block in run'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/spring-1.7.2/lib/spring/application.rb:125:in `loop'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/spring-1.7.2/lib/spring/application.rb:125:in `run'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/spring-1.7.2/lib/spring/application/boot.rb:19:in `<top (required)>'
from /Users/Joseph/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/Joseph/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
Is this normal? Or is there something wrong with my gems here?
There's nothing wrong with your gems. The thing is that when you run irb, it's just that. You only run the ruby interactive.
When you run rails console in order to show you the console it needs to go and set it for you with ActiveRecord, rails core, etc. So this (below) is all it does before it's set.
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/railties-5.0.0.1/lib/rails/commands/console.rb:65:in `start'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/railties-5.0.0.1/lib/rails/commands/console_helper.rb:9:in `start'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:78:in `console'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from /Users/Joseph/workspace/sample_app/bin/rails:9:in `<top (required)>'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `block in load'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/spring-1.7.2/lib/spring/commands/rails.rb:6:in `call'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/spring-1.7.2/lib/spring/command_wrapper.rb:38:in `call'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/spring-1.7.2/lib/spring/application.rb:191:in `block in serve'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/spring-1.7.2/lib/spring/application.rb:161:in `fork'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/spring-1.7.2/lib/spring/application.rb:161:in `serve'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/spring-1.7.2/lib/spring/application.rb:131:in `block in run'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/spring-1.7.2/lib/spring/application.rb:125:in `loop'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/spring-1.7.2/lib/spring/application.rb:125:in `run'
from /Users/Joseph/.rvm/gems/ruby-2.3.1#sample_app/gems/spring-1.7.2/lib/spring/application/boot.rb:19:in `<top (required)>'
from /Users/Joseph/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/Joseph/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
Notice that irb is executed really fast, while rails console takes its time, depending on your initializers, configurations, etc.

Shorten Error Message in Terminal

Rails error messages in terminal are too long and contain often useless information. Is there a gem/solution to shorten rails error messages?
Example:
2.2.2 :012 > puts 1.red
What I currently get:
NoMethodError: undefined method `red' for 1:Fixnum
from (irb):12
from /Users/Ben/.rvm/gems/ruby-2.2.2#global/gems/railties- 4.2.1/lib/rails/commands/console.rb:110:in `start'
from /Users/Ben/.rvm/gems/ruby-2.2.2#global/gems/railties-4.2.1/lib/rails/commands/console.rb:9:in `start'
from /Users/Ben/.rvm/gems/ruby-2.2.2#global/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/Ben/.rvm/gems/ruby-2.2.2#global/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/Ben/.rvm/gems/ruby-2.2.2#global/gems/railties-4.2.1/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/Ben/.rvm/gems/ruby-2.2.2#global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
from /Users/Ben/.rvm/gems/ruby-2.2.2#global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `block in require'
from /Users/Ben/.rvm/gems/ruby-2.2.2#global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/Ben/.rvm/gems/ruby-2.2.2#global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
from /Users/Ben/coding/krokoapp/bin/rails:8:in `<top (required)>'
from /Users/Ben/.rvm/gems/ruby-2.2.2#global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
from /Users/Ben/.rvm/gems/ruby-2.2.2#global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `block in load'
from /Users/Ben/.rvm/gems/ruby-2.2.2#global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/Ben/.rvm/gems/ruby-2.2.2#global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
from /Users/Ben/.rvm/gems/ruby-2.2.2#rails-devise-roles/gems/spring-1.3.6/lib/spring/commands/rails.rb:6:in `call'
from /Users/Ben/.rvm/gems/ruby-2.2.2#rails-devise-roles/gems/spring-1.3.6/lib/spring/command_wrapper.rb:38:in `call'
from /Users/Ben/.rvm/gems/ruby-2.2.2#rails-devise-roles/gems/spring-1.3.6/lib/spring/application.rb:183:in `block in serve'
from /Users/Ben/.rvm/gems/ruby-2.2.2#rails-devise-roles/gems/spring-1.3.6/lib/spring/application.rb:156:in `fork'
from /Users/Ben/.rvm/gems/ruby-2.2.2#rails-devise-roles/gems/spring-1.3.6/lib/spring/application.rb:156:in `serve'
from /Users/Ben/.rvm/gems/ruby-2.2.2#rails-devise-roles/gems/spring-1.3.6/lib/spring/application.rb:131:in `block in run'
from /Users/Ben/.rvm/gems/ruby-2.2.2#rails-devise-roles/gems/spring-1.3.6/lib/spring/application.rb:125:in `loop'
from /Users/Ben/.rvm/gems/ruby-2.2.2#rails-devise-roles/gems/spring-1.3.6/lib/spring/application.rb:125:in `run'
from /Users/Ben/.rvm/gems/ruby-2.2.2#rails-devise-roles/gems/spring-1.3.6/lib/spring/application/boot.rb:18:in `<top (required)>'
from /Users/Ben/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/Ben/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'2.2.2 :013 >
What I want: (optionally in red)
NoMethodError: undefined method `red' for 1:Fixnum
===>Long error message saved in e. Get full messages with 'puts e'
Would this be possible?
You could try better_errors gem.
It provides also a better explanation of the errors via browser.
This is the link to the github repo
EDIT
If you are looking also to a customizable console (also the exception trace) try to see pry

Unwanted lines in rails console error reporting

?> error
NameError: undefined local variable or method `error' for main:Object
from (irb):7
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/railties-4.2.0.beta4/lib/rails/commands/console.rb:110:in `start'
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/railties-4.2.0.beta4/lib/rails/commands/console.rb:9:in `start'
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/railties-4.2.0.beta4/lib/rails/commands/commands_tasks.rb:68:in `console'
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/railties-4.2.0.beta4/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/railties-4.2.0.beta4/lib/rails/commands.rb:17:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activesupport-4.2.0.beta4/lib/active_support/dependencies.rb:252:in `require'
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activesupport-4.2.0.beta4/lib/active_support/dependencies.rb:252:in `block in require'
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activesupport-4.2.0.beta4/lib/active_support/dependencies.rb:237:in `load_dependency'
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activesupport-4.2.0.beta4/lib/active_support/dependencies.rb:252:in `require'
from /home/ubuntu/workspace/sample_app/bin/rails:8:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activesupport-4.2.0.beta4/lib/active_support/dependencies.rb:246:in `load'
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activesupport-4.2.0.beta4/lib/active_support/dependencies.rb:246:in `block in load'
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activesupport-4.2.0.beta4/lib/active_support/dependencies.rb:237:in `load_dependency'
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activesupport-4.2.0.beta4/lib/active_support/dependencies.rb:246:in `load'
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/spring-1.1.3/lib/spring/commands/rails.rb:6:in `call'
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/spring-1.1.3/lib/spring/command_wrapper.rb:38:in `call'
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/spring-1.1.3/lib/spring/application.rb:180:in `block in serve'
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/spring-1.1.3/lib/spring/application.rb:153:in `fork'
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/spring-1.1.3/lib/spring/application.rb:153:in `serve'
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/spring-1.1.3/lib/spring/application.rb:128:in `block in run'
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/spring-1.1.3/lib/spring/application.rb:122:in `loop'
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/spring-1.1.3/lib/spring/application.rb:122:in `run'
from /usr/local/rvm/gems/ruby-2.1.4#rails4/gems/spring-1.1.3/lib/spring/application/boot.rb:18:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'
In rails console when I commit an error, the console displays tons of lines which I don't want to see. Can this be silenced?
I've found that you can add this line:
Rails.backtrace_cleaner.add_silencer { |line| line =~ /rvm/ }
in config/initializers/backtrace_silencers.rb but this doesn't resolve the problem.

Resources