0
レール方式:RailsのRabl宝石:クエリの子の親IDに基づいて
def index
user = Users.find(params[:user_id])
@countries = user.countries
@cities = user.cities
end
国のモデルにhas_many:都市
市モデルbelongs_toの:国
ユーザーが特定の国や特定のへのアクセスを持っています都市
対応するjson.rablファイル:
object false
child @countries do
child @cities.where(country_name: country.name) do
attributes :name, :coordinates
end
end
私の質問は、およそchild @cities.where(country_name: country.name)
私の目標は、現在の親の国の都市が含まれるように@citiesをフィルタリングすることです。
これはrablでも可能ですか?