Rails Console Broken - ruby-on-rails

I discovered today that my ruby console on rails is no longer working. (I don't work out of the console all that often, so not exactly sure when or how this happened). I'd like to get feedback on whether others have encountered this issue, and whether I should reinstall ruby, rails, or any other program or configuration.
When I enter
$ rails console
It gets me to what looks like the console, but anything I enter returns a NoMethodError, with undefined methods that are typos of what I actually entered.
For example, when I entered
irb(main):001:0> editor = Editor.new(name: "bob")
I get the response
NoMethodError: undefined method 'oews' for main:Object
from (irb):8
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands/console.rb:47:in 'start'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands/console.rb:8:in 'start'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:41:in <top (required)>'
from script/rails:6:in 'require'
from script/rails:6:in '<main>'
which seems to be a misinterpretation of the "new" method. Also, the railties-3.2.6 folder referenced above seems to be empty.
This happens in both my SQlite3 and PG environments.
Any insight on what may be causing this? I want to minimize the number of reinstallments if possible.
I'm currently running ruby 1.9.3 and rails 3.2.6
Thanks much!

Check that you are in the directory of the application. If you're on Mac or linux use the cd command.

The cause of the problem is still not clear.
A restart seems to have fixed it. Sorry, should have done so before posting the question.

Related

Rails 3.2.25 upgrade to 4.0.0 - "uninitialized constant ActiveRecord" on all active record queries

Im in the middle of performing an edge ruby and rails update for a web app built in rails 2.3.18 and running ruby 1.9.3.
I have been incrementally been updating the rails version and fixing breaks and things have been moving forward at a steady pace. I have currently made it to ruby 2.1 and rails 3.2.x.x. and have made the push to rails 4.0.0
I have dealt with alot of breaks and errors since the 4.0.0 update and can now get the server to start using rails s but im now getting a new error.
I cannot find literally anything about this error online so im hoping i'll have better luck here. Thx in advance.
This is the line in my controller that triggers this error. Keep in mind this is not my code. Im updating a 8 year old system.
class WpPosts < ActiveRecord::Base
establish_connection "blog"
end
This is the specific line that is firing off the error, but I get this error wherever the is any active record call. Even simpley calling a model in rails console get me this same error.
Things like calling User in rails console get me that same error.
I have already tried:
gem install activerecord -v=4.0.0
and that still gets me the same error. Ive also unistalled all other versions of activerecord.
There is a very short stack trace wich leads me to believe the railties lib is not loading. Or that maybe theres an issue with the path to that lib.
app/models/wp_posts.rb:1:in `<top (required)>'
app/controllers/default_controller.rb:28:in `start'
this is a screenshot of the top of my application.rb file

Rails Server and Console crashing because of unexpected break (LocalJumpError)

I'm getting this weird behaviour when running rails server or rails console.
The server/console crashes in various locations in the code throwing this exception:
script/rails:6:in `require': unexpected break (LocalJumpError)
from script/rails:6:in `<main>'
I must note that this behaviour happens to only one more person in my team, all other members of my team does not experience this behaviour and also production server is working just fine with no crashes like this.
Also, we found putting debugger somewhere in the code and just pressing continue solves this problem. But this is hardly a logic way to deal with this bug.
Does anyone experienced similar behaviour and knows how to solve this?
I have not enough information to provide a 100% sure solution, but here is my guess :
Try to use bundle exec rails <command> rather than script/rails <command>. Rails script doesn't have changed for some time, but it may just be you're not loading the correct gem dependencies.
It would be interesting to know if the other person of your team getting the problem is using script/rails too. If all other people having no problem use the rather idiomatic bundle exec rails, you have a good clue for a dependency version problem.

Routing/Config errors when upgrading to rails 4

I just installed Ruby 2 and Rails 4, and I created a new project. I made a devise user, and then I went to run the server. I got the error
/Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247#rails-4.0.0/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:10:in `rescue in execute_if_updated': Rails::Application::RoutesReloader#execute_if_updated delegated to updater.execute_if_updated, but updater is nil: #<Rails::Application::RoutesReloader:0x007f85ac132458 #paths=["/Users/michaeldunnegan/projects/SoundShare/config/routes.rb"], #route_sets=[#<ActionDispatch::Routing::RouteSet:0x007f85ac188e48>]> (RuntimeError)
I have absolutely no idea what to do. Configuration is pretty weird to me. I think the error might be in my path, whatever that is, but I can't be sure.
My rvm current looks like: ruby-2.0.0-p247#rails-4.0.0, if that's relevant
This is a known bug with rails 4 and devise.
Please see the rails issue on github

Heroku App Crashed No Errors In Log

Hi I am trying to deploy a small app on heroku
I managed to create the app, push the contents to the app, scaled it by one dyno but when I try to do heroku open, the app crashed and gave me error code 10
Here is the log file in paste bin
http://pastebin.com/Rh4iXn3Y
I found this error, uninitialized constant SimpleForm (NameError)
I uninstalled the simpleform gem but I figured it left behind some files that the gem didn't remove, I removed the file myself.
It should not throw me this error.
I am new to heroku, I know I need to dig through the doc to see how it works, but in the mean time can some one help me out?
thanks!
if you need more information please let me know.
From your log file:
2013-05-16T00:02:10.346211+00:00 app[web.1]: /app/config/initializers/simple_form.rb:2:in `<top (required)>': uninitialized constant SimpleForm (NameError)
Remove /app/config/initializers/simple_form.rb
Don't afraid of reading logs line by line. Near all answers are already there.

NameError: uninitialized constant Object::User

I searched the other posts that had this issue and could not find one that fixed my particular issue. My irb is going crazy. I am trying to change user roles in my database but I can't even get to my users!
irb(main):001:0> User.all
NameError: uninitialized constant Object::User
from (irb):1
from c:/Ruby192/bin/irb:12:in `<main>'
It was working fine, stopped working, was fine, and now stopped again. I have a User model and users added. I cannot pinpoint the issue. Let me know what code you need to see. Thanks!
You should run
ruby script/console # Rails < 3
or
rails c # Rails 3.x
But not (I believe you've just run this)
irb
Make sure you're actually using the rails console command rather than just running irb in your project folder.

Resources