Rails - Model changes not being saved or preserved between controller and model?

Self refers to the instance when used inside an instance method. It refers to the class outside an instance method, when it ( self ) is the class that's being defined.

Self refers to the instance when used inside an instance method. It refers to the class outside an instance method, when it (self) is the class that's being defined. @ is an instance variable, which is different than an ActiveRecord column.

In order to store it in the str field to be saved to the database, you need to use self. Str method. I think this is what you are looking for class Session To_i.

Times do str += some_method_in_MyHelper() # method returns a string end self. Str = str # store it in attribute to be saved into db end end Notice I removed the instance variable @str and changed it to local variable str instead because it seems like you want to generate a new string everytime this method is called? Also, this variable caching is useless @session ||= Session.

New because instance variables only stick around for a single request. It should be @session = Session.new.

True, instance variables exist per-request, but without knowing what else happens before create is called, overwriting what might already be in @session isn't necessarily a good idea. It's not just an idiom for caching. – Dave Newton Dec 3 at 21:33.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions