1

I was using this command to create a model class "Listing". However, I was interested in knowing the relationship between the datatypes of the model and the datatypes of the underlying database. In this case, it is PostgreSQL. So when I type this command:

rails generate scaffold Listing name:string

I want to know what are the possible values I can use to describe the types. What is that dependent on? The underlying database? If so then what happens if the underlying database changes later? Also, where can I get a list of the types I can use here and their capacity with an underlying db of PostgreSQL?

0

1 Answer 1

2

That command actually creates migrations for creating tables, etc, on the DB, so that's where you should check the types supported. I would copy/paste here but I think there is no need to.

http://guides.rubyonrails.org/migrations.html#supported-types

UPDATE

The link to the docs does not contain the information anymore. Go to this question Rails 4: List of available datatypes for the full list

Sign up to request clarification or add additional context in comments.

3 Comments

What about opotimizing the storage.If I want to use smallint versus int etc..... how does that work when using this command to create columns?
Well, you can use that command to generate for int, and later go to the migration file and change the line for that column, but remember to do this before running rake db:migrate
Your link no longer contains the "Supported types" section. The information is available in this answer: stackoverflow.com/a/17918118/1789900

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.