Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a transient attribute in Ruby on Rails?

Tags:

attributes

Can you explain a "transient attribute" in Ruby on Rails?

I'm reading the factory_girl Getting Started guide and its making reference to transient attributes. [https://github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md#defining-factories][1]

I understand "attribute" as an instance variables. But "transient attribute" vs. "attribute"; not so sure.

I'm new to Ruby on Rails and this would be helpful.

like image 769
tim_xyz Avatar asked Dec 04 '25 02:12

tim_xyz


1 Answers

"A transient attribute does not get persisted to the database. For instance, in one of my models, I have a transient attribute called last_updated_by. I don't save it to the database; I just use it during the processing of the model object by the controller."

Thanks J Plato!

like image 119
tim_xyz Avatar answered Dec 06 '25 15:12

tim_xyz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!