try @secret ||= ...

Bryan

MichelV69 wrote:
Heya, folks.  I have a mild case of "insufficiently clever";  I'm
hoping one of you can give me a hand.

When a "new" record is created, I wish to pre-populate the "secret"
field of the record with a randomly generated secret.  This is
working  The problem is that it _also_ happens on an "edit" of the
record;  over-writing the existing secret.

What I have now contained in the model is:

        def secret
                @secret = ( (@secret.nil? || @secret.size < 3) ?
generate_random_password(3) : @secret)
        end #secret

... is there a way to conditional vs the REST state, instead?  I can't
figure this out.

Thanks in advance.


--
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to