geo*_*boy 1 ruby-on-rails active-model-serializers
渲染时可以有条件的except,only或include选项吗?所以,就像下面的例子:
render json: @post,
except: [:author]
Run Code Online (Sandbox Code Playgroud)
是否有可能有条件的除外选项或类似的选项?
理想情况下,有条件的方式可以让我处理许多不同的条件和情况。
就像可能是这样的:
render json: @post,
except: return_excluded_keys
Run Code Online (Sandbox Code Playgroud)
return_excluded_keys 函数可以返回需要排除的键。
我正在使用 Rails 4.2.6 和 Active Model Serializers 0.9.3。
| 归档时间: |
|
| 查看次数: |
3653 次 |
| 最近记录: |