Reputation:
I'm looking to add a row to my "posts" database that can store an array that holds multiple user id's. I noticed that none of the other questions asked on here were using rails 4. I think that this is going to require me to serialize the information but I'm not sure how to do this.
thanks in advance!
Upvotes: 3
Views: 3834
Reputation: 1006
Create a migration
rails g migration AddSomethingToPosts something:text
In your model add
serialize :something, Array
here is more info: http://apidock.com/rails/ActiveRecord/AttributeMethods/Serialization/ClassMethods/serialize
also you can use store -> http://api.rubyonrails.org/classes/ActiveRecord/Store.html, and it probably will be a better choice :)
Upvotes: 5