Ruby on Rails. How to show record only once?

柔情痞子 提交于 2021-01-29 04:20:54

问题


I want to know how to show a record only exactly after it was created. So i want to show it only once.

Just see. I have model called Claim. User creates new Claim (user is anonymous). I want to show this Claim only ofter user creates it and never again. How can I do it?

I think that I can use flash hash, but i think it is not enough secure to create symbols from user data.


回答1:


You could have a viewed attribute on your model that you set to true in the show action. If viewed is true then skip rendering the view.

unless thingy.viewed 
  thingy.viewed = true
  thingy.save

  render like normal...
end


来源:https://stackoverflow.com/questions/1865110/ruby-on-rails-how-to-show-record-only-once

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