Reputation: 663
Ok, so I've installed xampp 1.7.7 and have my mysql database set up and everything. My database in phpmyadmin is named "spree-default-1.1_development" and my database.yml file looks like this:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: spree-default-1.1_development
pool: 5
username: root
password:
socket: /opt/lampp/var/mysql/mysql.sock
When I type "rails console development" it seems to load the console fine:
adnan@ubuntu:~/Documents/Aptana Studio 3 Workspace/spree-default-1.1$ rails console development
Loading development environment (Rails 3.2.3)
1.9.3-p194 :001 >
However, when I try to access anything in my mysql database, i get an error:
1.9.3-p194 :001 > Order
NameError: uninitialized constant Order
from (irb):1
from /home/adnan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands/console.rb:47:in `start'
from /home/adnan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands/console.rb:8:in `start'
from /home/adnan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I'm not sure why i cant access the models in the mysql database. My setup is in ubuntu 11.04, using rails 3.2.3 and ruby 1.9.3p194. When i load the rails server in aptana, i can run the server fine with localhost:3000 and it seems to connect to the database no problem.
When i use my Windows 7 setup with rails 2.3, I can access the models with no problem. typing "Order" will give me this result, which i expect:
>> Order
=> Order(id: integer, user_id: integer, number: string, item_total: decimal, total: decimal, created_at: datetime, updat
ed_at: datetime, state: string, token: string, adjustment_total: decimal, credit_total: decimal, completed_at: datetime)
Anyone know what is going on? I should be able to access the database fine using simple rails queries.
Upvotes: 2
Views: 2575
Reputation: 12273
In the current version of Spree (1.1+) you need to namespace the spree objects.
>> Spree::Order.first
Upvotes: 6