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.
Related
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
I am getting error in irb
NameError: uninitialized constant Student
for Student.new or whatever model operations are there.
But in rails it gives no error and it works fine. What would be the reason?
This error only happens in Windows, same code I have in Linux and there it works fine.
What makes the difference here?
irb has nothing to do with your rails project.
What you want instead is to run
rails console
from within your rails project directory. Here you have access to everything defined within the application - Rails loads everything automatically.
rails c
Create new tab in terminal. Here you may work with modals. Like CRUD operations.
But make sure your terminal must pointing in rails working directory before trying rails c command ...
I've got the extension spree_social_products installed in my spree 2.4.7 store on rails 4.1.8 and everything is working great except I cannot get the facebook intergration to configure.
The extension is here: https://github.com/spree-contrib/spree_social_products
I have an issue when trying to set my facebook app id.
The readme says run up a rails console and enter
Spree::Social::Config.facebook_app_id = 'YOUR_FACEBOOK_APP_ID'
When I run that command in the console I'm getting the following.
`<main>'2.1.0 :011 > Spree::Social::Config.facebook_app_id = 'XXXXX123456'`
NameError: uninitialized constant Spree::Social from (irb):11 from
/home/mspree/.rvm/gems/ruby-2.1.0#spree2.4/gems/railties-4.1.8/lib/rails/commands/console.rb:90:instart'
....
I running the command correctly ?
I've tried rails console and rails console development, both give the same error.
It turns out I had the wrong namespace and I had to create and set the value. I was expecting the variable to be present but it was not.
I found the following helpful.
https://groups.google.com/forum/#!topic/spree-user/Giuh5avHuRo
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.
I've recently tried to use the Vote_fu plugin to do some simple voting on my rails site. I was following this guide https://github.com/vshvedov/vote_fu_rails_3
I was able to download the plugin perfectly fine but when I tried to run rails g vote_fu MymodelName or rake db:migrate, they both returned uninitialized constant Juixe (NameError).
Has anyone else had this problem and do you have any solutions to help me fix it? Thanks for your help!
Edit: The full error is found here http://pastebin.com/3AMGUn44