Design Element
Comment on "Attribute Values in Rails"
by Jo — Nov 01
You can modify the example above and add an input value to def initialize:

def initialize(value); @hashofnames = value; end
def putshash; puts @hashofnames; end

Now you can read in a new hash into class HashOfNames:

newhash = {...}
putin =
puts putin.hashofnames
puts putin.putshash

Yet another option would be to use "...; value.scrub_attributes; ..." in def initialize(value) directly.
Back to "Attribute Values in Rails"
Design Element

Copyright © Scott Stevenson 2004-2015