# First time with Rails

**URL:** <https://www.ruby-forum.com/t/first-time-with-rails/57369>\
**Category:** Rails\
**Created:** [April 10, 2006, 12:43pm UTC](https://www.ruby-forum.com/t/first-time-with-rails/57369 "2006-04-10T12:43:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![neilbain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b487fb/32.png) [@neilbain](https://www.ruby-forum.com/u/neilbain)\
**Post date:** [April 10, 2006, 12:43pm UTC](https://www.ruby-forum.com/t/first-time-with-rails/57369/1 "2006-04-10T12:43:41Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![neilbain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b487fb/32.png) [@neilbain](https://www.ruby-forum.com/u/neilbain)\
**Post date:** [April 10, 2006, 3:27pm UTC](https://www.ruby-forum.com/t/first-time-with-rails/57369/2 "2006-04-10T15:27:55Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![neilbain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b487fb/32.png) [@neilbain](https://www.ruby-forum.com/u/neilbain)\
**Post date:** [April 10, 2006, 5:34pm UTC](https://www.ruby-forum.com/t/first-time-with-rails/57369/3 "2006-04-10T17:34:41Z")

</div>

Thanks for the reply! 🙂

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. ☹

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:in`constantize’  
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:in`paginator\_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:in`list’  
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:in`perform\_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:in`perform\_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:in`perform\_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:in`process\_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:in`dispatch’  
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:in`service’  
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:in`run’  
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:in`start\_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:in`start’  
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:in`start’  
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:in`require’  
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:in`require’  
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

---

<div class="post-metadata">

**Author:** ![neilbain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b487fb/32.png) [@neilbain](https://www.ruby-forum.com/u/neilbain)\
**Post date:** [April 10, 2006, 5:53pm UTC](https://www.ruby-forum.com/t/first-time-with-rails/57369/4 "2006-04-10T17:53:39Z")

</div>

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! 🙂
> 
> 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. ☹
> 
> 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:in`constantize’

::snip::

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

---

<div class="post-metadata">

**Author:** ![neilbain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b487fb/32.png) [@neilbain](https://www.ruby-forum.com/u/neilbain)\
**Post date:** [April 10, 2006, 5:50pm UTC](https://www.ruby-forum.com/t/first-time-with-rails/57369/5 "2006-04-10T17:50:30Z")

</div>

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
