[Rails] Re: how to create custom yaml
Is the result a Rails model? If so, easy, just build a string and insert your variables into the string. You can do this in a model method like so:
def to_yaml
yaml = "---"
yaml += "- name: #{self.device_name or wherever you store this}"
blah blah
so on
return yaml
end
On Thursday, February 21, 2013 7:08:18 AM UTC-5, Ruby-Forum.com User wrote:
I need to create a method that should return yaml in the following
format
---
- name: device-1
parameters:
app_folder: deploy_project
app_id: "1"
tar_file: deploy_project.tar.gz
profile_id: "3"
version_id: "2"
classes:
- install
I have all these values (device-1, deploye-project etc) captured into a
variable "result" that are coming from the database but i just need to
return them in the above format as a yaml using
puts yaml_obj = result.to_yaml
--
Posted via http://www.ruby-forum.com/.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/HPE1p9HJ7OEJ.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home