Virtual attributes in rails 4

ぃ、小莉子 提交于 2019-12-03 06:11:29

Using virtual attributes in Rails 4 pretty much the same as with attr_accessible. You just have to add your virtual attribute to the permitted params in your controller (instead of attr_accessible), then add the getter and setter methods as usual in your model.

# your_controller.rb
private

def your_model_params
  params.require(:your_model_name).permit(:tags_list)
end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!