similar to: fixtures, how to set a serialized Hash object

Displaying 20 results from an estimated 6000 matches similar to: "fixtures, how to set a serialized Hash object"

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
2006 Aug 09
0
Ordering Fixtures
I''m trying to extract_fixtures using the example from the Recipes book but I want to extract them in order (by id) Does anyone know how to do that? data = sorted_array_of_objects_by_id file.write data.inject({}) { |hash, record| hash["#{table_name}_#{i.succ!}"] = record hash }.to_yaml -- Posted via http://www.ruby-forum.com/.
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 {
2010 Dec 17
1
flash[;notice] not display after redirection
I read all previous posts about the same subject in Devise group but couldn''t find any answer, so iy may not be related to Devise , so I debugged it .. . class Users::RegistrationsController < Devise::RegistrationsController .. # POST /resource/sign_up def create build_resource if resource.save if resource.active? set_flash_message :notice, :signed_up
2011 Apr 23
3
Rails3 how to scope it, using a serialized array ?
giving a simple model, with a serialized Array attribute class Instructor < User .. serialize :languages, Array I am looking in defining scopes like this : >scope speaking_english, lambda { where("languages ... includes.... ?", :en) } which look for instructors in which the languages array include ":en" Is this kind of scope possible ? or not.... ( just using
2011 Feb 27
10
How to store the same key multi times in a Hash ?
given an Arra tags[] I need to produce a resulting Hash as following .. { "$in" => [tags[0]], "$in" =>[tags[1], ...} in which the key should be always the same and the value being an Array I tried this : myHash = {} tags.each do |tag| h = {"$in" => [tag]} myHash.merge!(h) end but the merge! is only
2007 Feb 07
0
strange sqlite3 errors - validates_associated & failing activerecord unit tests
I''m getting two strange errors, both which I believe relate to sqlite3. The first one is with validates associated. Here is my test: require File.dirname(__FILE__) + ''/../test_helper'' class SubscriptionPlanTest < Test::Unit::TestCase fixtures :subscription_plans fixtures :publications def setup @six_month_gold = subscription_plans(:six_month_gold)
2006 Mar 28
0
Question about Mapping from Forms
During a load or save in my controller I''ve manually been doing: @myobject = MyObject.find(:first, :conditions => "id = #{@params[''id'']}") If I''m updating an existing object I load it, change stuff using something like myobject.name = "@params[''name'']", etc etc, then call save. That''s what I''ve done in
2009 Nov 23
1
OOP with Encapsulated Class Definitions
Hi all, I'm seeking feedback (good, bad or indifferent) in regards to developing (further) a new class system for R, that uses encapsulated class definitions (i.e. the method definitions are literally inside the body of the class definition). A working (however very rough and poorly tested) system is available in my R package "oosp" with documentation in the vignette
2011 Dec 25
1
Fixtures vs Fixture class, what is the intended purpose?
Hello, i am trying to fix the code for fixtures in rails because it is buggy and internal variable names are confusing, could somebody please explain to me what is the intended purpose of Fixture and Fixtures classes respectively? For example, why do we need both `Fixtures.initialize`and `Fixture.initialize`? They both "initialize" a single fixture, and in fact `Fixture.initialize`
2006 Dec 12
0
S4 property slots as functions?
Dear R users! Several languages like C# or VB allow one to create properties; typically these are under 'get', 'set' tags. My question is this really, what are similar or comparable strategies in R, and what might be preferred? I have a couple of situations where I want a certain computation to belong to a class, but I do not really want to seperate it out to a stand-alone
2006 Dec 12
1
S4 'properties' - creating 'slot' functions?
Dear R users! Several languages like C# or VB allow one to create properties; typically these are under 'get', 'set' tags. My question is this really, what are similar or comparable strategies in R, and what might be preferred? I have a couple of situations where I want a certain computation to belong to a class, but I do not really want to seperate it out to a stand-alone
2010 Mar 23
0
Frozen hash problem
I''d like to delete some records before saving them. I ran this experiment: before_save :prune_lab_datas def prune_lab_datas lab_datas.each do |lab_data| lab_data.destroy end raise lab_datas.to_yaml end But nothing seems to be deleted in the hash: --- - &id001 !ruby/object:LabData attributes: created_at: 2010-03-21 22:16:06 unit_id: "3"
2008 Jan 09
1
Subsetting Method [ Revisited
Hello Everyone: As usual, thanks in advance for any help. I was hoping to get some more advice on this question: I'm trying to write a subsetting routine for an S3 object I've created -- lets call it myObject. myObject has a few attributes basically of type string and numerics. Its atomic value is just a vector of ints. I want to write my own subsetting routine to subset myObject in
2006 Aug 04
2
RoR: recognizing a defined class
Hi all, I am very new to Ruby and I have a silly question: how do I get RoR to "recognize" that I just defined a class? To be more explicit, I have a controller and view, and then I want to create a class and get the controller to "see" it. So, I created a file called "myobject.rb" in the models/ directory and inside it defined "class myobject [...] end".
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
2006 May 24
2
newbie oo question
Hey everyone, I''m trying to create an object that will have some properties predefined, but will allow me to pass in properties to override those standard props if needed. I''m trying something like: var myObject = Class.create(); myObject.prototype = { initialize: function(element, options) { this.element = $(element); this.name = this.element.id; this.options =
2006 May 23
2
Putting fixtures into subdirectories
I want to organize my fixtures just like the namespace of my models. So for example if I have a model Company::Employee I''d like the fixture to be in fixtures/company/employees.yml. However, I can''t figure out how to specify the path of the fixture file. If I do: fixtures :employees in my unit test it can''t find the fixture file. Any suggestions? Thanks, Todd
2006 Jul 31
0
using Class#Find in dynamic fixtures
Hi, I am currently coding my tests and I made a lot of fixture files. To make everything simple (I thought), I didnt put the ID in the fixture, insted when I needed to put the id of something, I used Class.find_by_name "name of the item to find". When I use the file to import data in my migration everything is fine. But when I use the same files for my unit test, there is a
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: