Displaying 20 results from an estimated 20000 matches similar to: "YAML fails when has_one is null"
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 {
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
2007 Oct 07
1
How to store a Mechanize object in the database?
Hi,
I am trying to save a Mechanize object in database (using a Rails Model).
But the save operation throws a TypeError
Considering that "agent" is an instance of a Rails Model and "user" is
defined as a "text" type in the Model.
irb(main):039:0> agent.user = WWW::Mechanize.new
#<WWW::Mechanize:0xb71295f0 @follow_meta_refresh=false, @key=nil,
2012 Dec 14
11
Puppet and Mcollective yaml file changing when it shouldn't
Has anyone else ran into this?
debug: /Stage[main]/Mcollective/File[/var/tmp/facts.yaml]/content:
Executing ''diff -u /var/tmp/facts.yaml
/tmp/puppet-file20121214-13448-933j3r-0''
notice: /Stage[main]/Mcollective/File[/var/tmp/facts.yaml]/content:
--- /var/tmp/facts.yaml 2012-12-14 00:53:20.000000000 +0000
+++ /tmp/puppet-file20121214-13448-933j3r-0 2012-12-14
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 class, or
how can I access the
2008 Sep 16
3
has_one :through eager-loading problem
I have a problem with the :include option in find for my
has_one :through association.
I have Users, Profiles and Customers, all connected to each other with
a has_one :through => :membership association like this:
class Profile < ActiveRecord::Base #could also be user or customer
has_one :membership # i saw an acrticle of Ryan about
has_one :through, there this would be has_many, is
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 "Ruby on Rails:
2009 May 25
4
after_create and has_one association bug?
Hello,
I''ve come across an issue that I''m sure is a bug when using after_create
with a has_one association, but I''m not 100% certain if I''m missing
something.
This is pretty much exactly the code I''m using. Two simple classes
(Account and Contact) and I create the contact after I create an account
(via after_create). I''m not passing in a
2006 Apr 20
5
Mystified by ActiveRecord.serialize
I''m either missing a step, confused or seeing some odd behavior with
ActiveRecord''s serialize feature. When I load an ActiveRecord object
from the database, my serialized attribute is a YAML::Object, not the
original object. My code is based on an example of this capability in
the "Agile Web Dev. w/ Rails" book (p. 196).
In create.sql:
<code>
create table
2008 Sep 29
1
has_one :through with :source. How to alias association?
Hi to everyone,
I have the following models:
class Attachment < ActiveRecord::Base
has_attachment :content_type => [:image, ''application/pdf''],
:max_size => 3.megabytes,
:path_prefix => ''../private/attachments'',
:storage => :file_system,
:processor => :rmagick,
2011 May 06
3
Reading Yaml files and getting an 'uninitialized constant ActionView::CompiledTemplates' Error
Want to load a configuration from a yaml file ala config/database.yml. I am
following http://blog.innovativethought.net/2009/01/02/making-configuration-files-with-yaml-revised/
but, I am getting uninitialized constant
ActionView::CompiledTemplates::DOMAIN_CONFIG from rails. I''ve documented my
code to make this simpler. I''m running Rails 3.0.7
I know isn''t the
2006 Feb 17
3
Using :include with has_one vs. has_many
While I''m happy to continue talking about the vagaries of Rails deployments, I
also need to actually build apps. :)
I may have discovered a bit of a problem with :include as it applies to has_one
associations. First, let me say that I''m a big fan of :include for reducing the
number of SQL calls. There are times when I wish it could go more than 1 step
away from the parent
2006 Apr 15
1
Is this a HAS_ONE bug?
Let''s say I have:
A BELONGS_TO B
B HAS_ONE A (with :dependent=>:nullify)
But this association does not need to exist. In other words, I could
have many A''s and B''s that are not associated in this manner.
Presently, if I try to delete "B":
1. If B is associated to an "A", this works fine and A.my_B is
nullified.
2. If B is NOT associated, I
2006 May 16
1
:conditions on has_one realationship
Hi there,
I''m currently building a membership application and I want to be able
to select, not just all the memberships, but the most current
membership from the database on a per user basis. I have linked the
tables as shown:-
class Membership < ActiveRecord::Base
belongs_to :payment
belongs_to :person
end
class Person < ActiveRecord::Base
has_many :memberships
2013 Mar 21
0
how to remove changed_attributes from yaml response
Hi,
I am using attr_accessor attributes in model class and assigning the
values to attr_accessor dynamically in controller. And am sending the
data object to display in Yaml format. I am getting the response along
with changed_attributes but I don''t want changed_attributes details in
my response.
build Model code
class Test < ActiveRecord::Base
attr_accessor: t_1, t_2, t_3, t_4
end
2011 Mar 07
1
has_one :dependent => :destroy error (in `configure_dependency_for_has_one': compile error (SyntaxError))
Hi I''m getting the following error :
/Users/nikosd/.rvm/rubies/ree-1.8.7-2011.02/bin/ruby -e
$stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)
/Users/nikosd/.rvm/gems/ree-1.8.7-2011.02@.../bin/rake test
Testing started at 12:00 PM ...
(in /Users/nikosd/Work/.../.../...)
2006 Sep 27
5
Question about has_one
I have a question about regarding the use of ''has_one'' in this scenario:
Schema:
User
----
id
first_name
last_name
UserMessage
----
user_id
message_id
Message
----
id
Assuming business rules dictate that a Message can have at most ONE User
(let''s assume a message can be created without a user associated to it),
these are my questions:
1) How would I use has_one
2006 Mar 03
6
has_one :next - invalid name?
I have this in a model:
has_one :next,
:class_name=>''WorkPart'',
:foreign_key=>''next_id''
And it causes this error:
compile error
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.1/lib/active_record/deprecated_associations.rb:83:
void value expression
2006 Jan 12
0
yaml: custom saving and loading of specific classes
I''m trying to use ruby''s yaml library to serialise and deserialise some
legacy classes. Simply adding a to_yaml_properties() method isn''t
sufficient as special methods need to be called to get and set the
properties (they''re not stored simply in instance variables that I can
access), and I don''t want to change the class any more than I have to.
2006 Jun 21
1
ActiveRecord has_one default value
My apologies if this is a dumb question, but I''ve searched around and
haven''t been able to come up with a solution.
Is there a way when specifying a has_one association to specify a
default value for an object if data is missing in the child table. For
instance:
class Student
has_one :university
end
if no university is associated to the student in the database, I would