I saw in a post that was not necessary to specify the type string for some column. But it didn't say which Rails he was using and the ruby guide put the :string anyway. In which version is that required ?
Asked
Active
Viewed 31 times
0
-
what post did you see this in? – dax Sep 20 '13 at 13:16
-
what do you mean by 'some'? – Miotsu Sep 20 '13 at 13:16
-
I don't know if it is necessary, but you have to set the type of the column in the DB, Rails can't decide for you (!). – MrYoshiji Sep 20 '13 at 13:23
1 Answers
0
Actually, it's not necessary. Look here, at the Rails::Generators::GeneratedAttributes#initialize
source. You'll see the line:
@type = type || :string
So if you omit column type in generating model, it will be set by default to string. Thanks, BTW, it was nice to learn.

Marek Lipka
- 50,622
- 7
- 87
- 91