views:

55

answers:

1

Hello.

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  A: 

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
Andy Gaskell
I was thinking about it. But maybe there are more Rubyish ways to do it...
Igor Alexandrov
I would go with this. Seems like a pretty solid solution.
Ryan Bigg
Oh, I must note that I would use update_attribute(:viewed, true) rather than setter than save though.
Ryan Bigg
Ok, but maybe somebody will add solution, that will not use database column?
Igor Alexandrov