On Feb 11, 2010, at 11:54 PM, MichelV69 wrote:



On Feb 11, 11:47 pm, MichelV69 <[email protected]> wrote:

... is there a way to conditional vs the REST state, instead?


Matt answered this in a different thread I just saw.  So:

        def secret
                @secret = ( ( new_record? ) ? generate_random_password(3) : 
@secret)
        end #random_password

... however, this _blanks_ the "secret" form field on any "not
new_record?" condition... I can't figure out how to access the current
value of the current record's secret here.

This is actually more of a Rails problem than a Hobo problem - you're overriding the accessor, so you'll need to do the lifting that AR typically does (read_attribute).

This should work

def secret
  @secret ||= read_attribute(:secret) || generate_random_password(3)
end

--Matt Jones

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