First time with Rails

Hi this is my first time with Rails and I’m having problems getting it
to work properly. In the Database.yml file I have set up the following -

development:
adapter: mysql
database: cars
username: *****
password: *****
socket: /path/to/your/mysql.sock
host: *****

But, when I launch the controler it says -

NameError in Add_car#index

uninitialized constant Car

Where am I going wrong, as the database is not on localhost is there
anything wrong in what I have done?

If your MySQL server is not on localhost, you probably should connect
via a hostname and a port number (usually 3306), not by specifying a
socket, just like in any other environment. Read the comments in the
database.yml, which gives an example.

Look at how you connect to that MySQL server from your machine with
other tools. Those are the settings you should use.

However, you may be happiest developing with a local database so you can
work without a net connection at all if need be.

Neil Bate wrote:

Hi this is my first time with Rails and I’m having problems getting it
to work properly. In the Database.yml file I have set up the following -

development:
adapter: mysql
database: cars
username: *****
password: *****
socket: /path/to/your/mysql.sock
host: *****

But, when I launch the controler it says -

NameError in Add_car#index

uninitialized constant Car

Where am I going wrong, as the database is not on localhost is there
anything wrong in what I have done?

Thanks for the reply! :slight_smile:

I’m afraid it has to be done through the web database, as it eventually
has to be moved to another machine and the database is already set-up.
I’ve put the same into in what I use to connect though MySQL front and
it still does nothing with the Scaffold Cars command in the AddCar
controller. :frowning:

database.yml -

development:
adapter: mysql
database: cars
username: ***
password: ***
host: .***.***.***.
port: 3306


Error message -

uninitialized constant Car

RAILS_ROOT: ./script/…/config/…

C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:200:in
const_missing' C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/core_ext/string/../../inflector.rb:149:inconstantize’
C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/core_ext/string/inflections.rb:52:in
constantize' C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:186:inpaginator_and_collection_for’
C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:124:in
paginate' C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/scaffolding.rb:101:inlist’
C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/scaffolding.rb:94:in
index' C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:inperform_action_without_filters’
C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/filters.rb:332:in
perform_action_without_benchmark' C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:inperform_action_without_rescue’
C:/INSTAN~1.0/ruby/lib/ruby/1.8/benchmark.rb:293:in measure' C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:inperform_action_without_rescue’
C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:82:in
perform_action' C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:inprocess_without_session_management_support’
C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/session_management.rb:116:in
process' C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:indispatch’
C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:117:in
handle_dispatch' C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:inservice’
C:/INSTAN~1.0/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in service' C:/INSTAN~1.0/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:inrun’
C:/INSTAN~1.0/ruby/lib/ruby/1.8/webrick/server.rb:173:in start_thread' C:/INSTAN~1.0/ruby/lib/ruby/1.8/webrick/server.rb:162:instart_thread’
C:/INSTAN~1.0/ruby/lib/ruby/1.8/webrick/server.rb:95:in start' C:/INSTAN~1.0/ruby/lib/ruby/1.8/webrick/server.rb:92:instart’
C:/INSTAN~1.0/ruby/lib/ruby/1.8/webrick/server.rb:23:in start' C:/INSTAN~1.0/ruby/lib/ruby/1.8/webrick/server.rb:82:instart’
C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:69:in
dispatch' C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webrick.rb:59 C:/INSTAN~1.0/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:inrequire’
C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
require' C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28 C:/INSTAN~1.0/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:inrequire’
C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
`require’
script/server:3

This error occured while loading the following files:
car.rb

Can we see your schema for the cars table and also the contents of your
controller and your model? I’d like some confirmation that you have a
schema called cars and a table called cars in place, for starters.

Neil Bate wrote:

Thanks for the reply! :slight_smile:

I’m afraid it has to be done through the web database, as it eventually
has to be moved to another machine and the database is already set-up.
I’ve put the same into in what I use to connect though MySQL front and
it still does nothing with the Scaffold Cars command in the AddCar
controller. :frowning:

database.yml -

development:
adapter: mysql
database: cars
username: ***
password: ***
host: .***.***.***.
port: 3306


Error message -

uninitialized constant Car

RAILS_ROOT: ./script/…/config/…

C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:200:in
const_missing' C:/INSTAN~1.0/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/core_ext/string/../../inflector.rb:149:inconstantize’

::snip::

This error occured while loading the following files:
car.rb

Neil Bate wrote:

database.yml -

development:
adapter: mysql
database: cars
username: ***
password: ***
host: .***.***.***.
port: 3306


Error message -

uninitialized constant Car

I think the problem you could be having is that your database name is
cars, and guessing you have a Model called Car.

Try calling your database cars_development like this: -
database: cars_development

that might work