search for: to_yaml

Displaying 20 results from an estimated 70 matches for "to_yaml".

2012 Jul 05
1
hash to_yaml in erb template not giving valid yaml
Hi, I want to use a file resource to write a facts.yaml file for Mcollective. For some reason it won''t provide a valid yaml format if I dump my scope to hash and convert to_yaml. file { "/etc/mcollective/facts.yaml" : owner => root, group => root, mode => 400, loglevel => debug, #content => inline_template("<%= scope.to_hash.reject { |k,v| !( k.is_a?(String) && v.is_a?(String) ) }.to_yaml %>"), #conten...
2010 Jul 17
1
not able to find to_yaml definition
I am looking at rails edge source code. I am able to do puts User.find.to_yaml However I am not able to find piece of code where ''def to_yaml'' is. How this to_yaml serialization is working? can fully understand how to_json and to_xml is working but to_yaml beats me. Thanks -- You received this message because you are subscribed to the Google Groups &q...
2006 Jun 23
0
to_yaml problem with option hash
Hi, I''m trying to make a fixture for testing with a serialized column. In the YAML fixture I''m trying to fill the serialized column with the to_yaml function. But I keep getting the ''---'' separator, which I don''t want because it is only a ''partial'' yaml fill. According to the documentation to_yaml takes a hash of options, so something like .to_yaml( :Indent => 4, :Separator => '''...
2007 Oct 07
1
How to store a Mechanize object in the database?
...], open_timeoutnil, connection_cache{}, cookie_jar#<WWW::Mechanize::CookieJar:0xb71295b4 @jar={}>, proxy_usernil, digestnil, passwordnil, redirect_oktrue irb(main):040:0> agent.save TypeError: can''t dump anonymous class Class from /usr/lib/ruby/1.8/yaml/rubytypes.rb:6:in `to_yaml'' from /usr/lib/ruby/1.8/yaml/rubytypes.rb:18:in `node_export'' from /usr/lib/ruby/1.8/yaml/rubytypes.rb:18:in `add'' from /usr/lib/ruby/1.8/yaml/rubytypes.rb:18:in `to_yaml'' from /usr/lib/ruby/1.8/yaml/rubytypes.rb:17:in `each'...
2006 Jan 11
0
Limit attributes written out by to_yaml
...39;''' minimum_value: '''' item_id: 153 default_value: '''' ... many more fields However I don''t want all these fields. How can I limit the YAML output to just include the fields that I want? I know that I can override to_yaml_properties to specify the fields that i want from a class. But that really only lets me choose whether I want to export @attributes or not. I think that I could override to_yaml_properties of @attributes. Something like this class Item class <<@attributes def to_yaml_properties...
2012 Dec 03
4
Unnecessary changes when creating facts.yaml
I have set up puppet to create a facts.yaml file for mcollective using the following line: content => inline_template("<%= scope.to_hash.reject { |k,v| k.to_s =~ /(uptime.*|timestamp|.*free|macaddress.*|ipaddress)/ }.to_yaml %>"), However, it is creating a lot of unnecessary changes by reordering the facts in the yaml output as you can see in the diff output between to runs; --- facts.yaml 2012-12-03 10:25:15.389570751 +0000 +++ facts.yaml.copy 2012-12-03 10:24:31.982563969 +0000 @@ -5,14 +5,14 @@ clientc...
2012 Dec 14
11
Puppet and Mcollective yaml file changing when it shouldn't
...file resource -- "/var/tmp/facts.yaml": owner => root, group => root, mode => 400, loglevel => debug, content => inline_template("<%= scope.to_hash.reject { |k,v| k.to_s =~ /(uptime_seconds|uptime_hours|timestamp|free)/ }.to_yaml %>") Any thoughts or suggestions? Seems like an odd one to me. -Z -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/KWkrTqkvwXcJ. To post t...
2011 Oct 25
7
additional model attributes
Hi, i have a "place" model with 2 columns (id, name). I''m calling an external api which gives me data to create a new place object. I would like to add the address from the external place to the place object and render it as a json result, without storing it in the database. i don''t get any errors, but the address never shows up within the json output. i''ve
2008 Oct 21
6
detecting width overflow in serialized column with mysql
So I''ve got an ActiveRecord model pointing to a MySQL db, with an auto-serialized column ("serialize :columnName"). Thing is, MySQL, depending on how it''s configured (like, by default), has a bad habit of just truncating your data if it''s too wide for the column, with no error raised. Yeah, I can probably reconfigure MySQL and/or my AR connection to it. But
2011 Mar 29
0
Issue / code smell in AssociationProxy
I came across an issue in my code and after a hard debug session I found something that smells. First the context of my issue. I have a AR object that has a polymorphic belongs_to currently tied to nothing, I want to dump it to YAML. record.to_yaml This raises the following exception: TypeError: wrong argument type nil (expected Data) from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/ lib/ruby/1.8/yaml.rb:391:in `emit'' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/ lib/ruby/1.8/yaml.rb:39...
2009 Nov 10
10
Un-recognised routes that do exist, using namespaces & subdomain checking
...tion. module Foo module RouteSetExtensions def self.included(base) base.alias_method_chain :extract_request_environment, :debug base.alias_method_chain :recognize_path, :debug end def recognize_path_with_debug(path, environment={}) puts path puts environment.to_yaml recognize_path_without_debug(path, environment) end def extract_request_environment_with_debug(request) env = extract_request_environment_without_debug(request) puts env.to_yaml env end end end ActionController::Routing::RouteSet.send :include, Foo::RouteSet...
2010 Dec 17
1
flash[;notice] not display after redirection
...y. However, we could not sign you in because your account is unconfirmed."} hiwever when the home page is displayed ... ( layout code ..) #content_wrapper #content %p.notice = flash.to_yaml = notice %p.alert = alert = yield and I got an empty flash ... (flash.to_yaml ) --- !map:ActionDispatch::Flash::FlashHash {} I don''t think the "expire_session_data_after_sign_in! " in the controller doe...
2008 Mar 10
2
response.body == filename?
I''m using RSpec. describe UserController do it "should require ..." do post :login, {:name => ''root''} puts response.body.to_yaml end end ....--- user/login ????? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org...
2007 Mar 29
1
Extending the to_s method
...purposes) and I wanted to extend the to_s method for the Time class. What I want to do: when someone does date.to_s(:short) that a localized version of the :short date is displayed. But I don''t know how to accomplish this. I know have this: class Time def to_s(option) print option.to_yaml ''lalo'' end end Jepp... it prints all the the times to ''lalo'' :) But how do I adjust this method so that only in the case of :short the return value is modified? Something like: if option == :short { return self.strftime("%Y %D %E") } Or is t...
2007 May 29
1
YAML fails when has_one is null
My model has_one :association If I call model.to_yaml (or y model) in the console, and the association is nil, I get a yaml error. Anyone else get this? Is this a confirmed bug? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To p...
2009 Apr 09
1
method_exists? is missing?
In a controller run through webrick I do this: @entity = Entity.new print @entity.methods.sort.to_yaml and I see this: - logger - mark_for_destruction - marked_for_destruction? - metaclass - method - method_missing - methods - new_record? There is no method_exists? method. If I instead do this in a console session, I see this: $ script/console >> >> @entity = Entity.new => ... &...
2009 Jul 21
2
About Error handler
Hi I am new to ruby on rails I need to know one thing Is there any way to externalize all the error messages in one file and access -- Karthik.k Mobile - +91-9894991640
2006 May 17
6
ActiveRecord#to_param
Hello, to implement some some kind of optimistic locking, I want to build a view, where an object is displayed together with a link containing the data of the displayed object. My first try looked something like <%= object.object_discription %> <%= link_to "action", :action => "take_action", :data => object %> this won''t work because object is of
2008 Apr 16
2
Question about yaml. Thank you !!
Hi friends: I tried to convert a model object to yaml(use to_yaml method), and after that, I would like to convert the yaml(string type) back to the model object. But when I use YAML::load to do that, it failed, the return object''s class is Yaml class, not my prior model class.. Please tell me how can I do to convert yaml to an object as the prior model...
2007 Feb 07
0
strange sqlite3 errors - validates_associated & failing activerecord unit tests
...ication_id) assert_valid pub, "publication errors: #{pub.errors}" assert_valid sub_plan.publication, "sub_plan.publication.errors: #{sub_plan.publication.errors}" assert_equal sub_plan.publication_id, pub.id assert_valid sub_plan, "errors: #{sub_plan.errors.to_yaml}" end private # just a little util method to create a record with the necessary parameters def create(h={}) SubscriptionPlan.create({ :price => 55.25, :duration_in_months => 17, :publication => @gold, :active => false }.merge(h)) end end An...