storing arrays and dictionaries

since activebase doesn't seem to recognize the idea of a collection of information (like a list of people who've liked a status/post, or a list of place's someone's been and when they went there), is there any way that make it so that this information is actually held inside a text row?

for example the model would be

bin/rails generate model Post User:belongs_to Comment:has_many body:text title:string likedusers:text

the data for an example post (with the format being "username" => "user_id") would look like:

body = "This is an example post with example words and example letters"

title = "Example Post"

likedusers = "John Doe" => "456", "JaneDoe" => "123", "GeorgeWashington" => "789"

how can i get rails to do something like this??

1 thought on “storing arrays and dictionaries”

  1. Something like this gem might be what you are looking for: https://github.com/ryanto/acts_as_votable

    That gem might be a little bit too much, in which case you could try something like this and use Rails’s associations.

    class User < ActiveRecord::Base has_many :likes has_many :posts end class Like < ActiveRecord::Base belongs_to :user belongs_to :post end class Post < ActiveRecord::Base has_many :likes belongs_to :user end

    Reply

Leave a Comment