Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I am aware of t.text :tags, array: true, default: [] this syntax in migration to create an array of data type text. Can I do the same in the rails generator itself?
t.text :tags, array: true, default: []
You can do this following as:
rails g scaffold Todo tags:array
And you can check migrate file which was generated:
migrate file
class CreateTodos < ActiveRecord::Migration def change create_table :todos do |t| t.array :tags t.timestamps null: false end end end
Add a comment
You can use array itself if you use a supported database like postgresql
rails g resource Todo tags:array
Required, but never shown
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.
Explore related questions
See similar questions with these tags.