Vote count:
0
I'm mocking out some sample data for a landing page. I'm loading the objects from a YAML file. I need to additionally assign some "accessory" data to each object that are not attributes from my schema.
@data = YAML.load_file("#{Rails.root}/lib/tasks/sample_foo.yml")
---
- !ruby/object:Foo
attributes:
username: jdoe
text: Hello World
customer_type: A # Not a Foo attribute
- !ruby/object:Foo
attributes:
username: mnort
text: Hi
customer_type: B # Not a Foo attribute
This doesn't work because customer_type
is not a Foo
attribute.
I would just use hashes, but I need to load the data as objects to use pre-existing view partials for these objects.
asked 41 secs ago
Aucun commentaire:
Enregistrer un commentaire