29. 解決1
タグを別のテーブルに分ける
class Post < ActiveRecord::Base
has_many :taggings
has_many :tags, through: :taggings
end
class Tagging < ActiveRecord::Base
belongs_to :post
belongs_to :tag
end
class Tag < ActiveRecord::Base
has_many :taggings
has_many :posts, through: :taggings
end
@tag.posts
42. as_json
class User < AvtiveRecord::Base
def as_json
{
id: id,
name: name,
evaluations: evaluations.as_json
}
end
end
class UsersController < ApplicationController
def index
@users = User.all
end
end