I have a scaffold, but it fails because the text of the users is longer than string permits. So I would like to change the kind of data, rails g scaffold Dreams Dream:string
for Dreams:text
,
It is possible?
Modify scaffold :string for :text
694 views Asked by user2284348 At
2
There are 2 answers
4
On
First of all, the scaffold should be a singular noun like User
and in your case, it should be Dream
, Rails will not allow Dreams
unless you pass --force-plural
option.
Second, the column name should also be singular, though it can be plural, but rails convention in general is to have singular column names.
And yes, you are right!
rails g scaffold Dream dream:text
text
is the option you are looking for. And if you do not specify anything with dream
, Rails will take it as string
.
If you have already migrate, undo it:
And redo it
You don't need to make
rake db:rollback
andrake db:migrate
if you have just generated your scaffold.If it is not your last migration, you can undo it with:
You can create a new migration:
and open migration to use
change_column
Finally,
rake db:migrate
.