在rails中渲染json时,如何从包含的关联中排除条目?

时间:2015-07-17 03:28:27

标签: ruby-on-rails ruby json

我有以下一行......

render json: { user: @user.as_json(except: :password_digest, include: :currency), token: token}

但是,我想except来自所包含货币关联的元素。我怎么能这样做?

1 个答案:

答案 0 :(得分:3)

render json: { user: @user.as_json( except: :password_digest,
  include: { currency: { except: :your_element } } ), token: :token }