Displaying 20 results from an estimated 600 matches similar to: "Issue / code smell in AssociationProxy"
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,
2006 Jun 20
2
Problem with "can''t dump anonymous class Class"
I submitted this earlier, but the web forums went down and I''ve screwed up
the thread, so I''m starting over.
I''m trying to built a document upload system. The system has a main
Document model with different subclasses for different types of documents.
With the code below, if I attempt to create a Document, it works fine, but
if I attempt to use one of the subclasses, I
2008 Feb 22
2
marshaling ActiveRecord objects: how to unload associations?
I''m marshaling ActiveRecord objects, and I want them to be as small as
possible. How can I unload everything that can be reloaded from the
database?
If they''re marshaled before any of the associations are referenced
then the referenced objects aren''t dumped. But if the association has
been loaded, how can I unload it? AssociationProxy.reset doesn''t seem
to do
2008 Feb 02
0
Adding methods to Object in Rails -- WARNING
I wanted to do:
foo.wrap
and wrap would go to a specialized wrap for some types of foo and a
general Object#wrap for all the others.
So I added wrap to Object
class Object
def wrap
self
end
end
This worked except for objects which are actually AssociationProxy
objects pretending to be some other object. The reason is that
AssociationProxy removes all but a few methods from itself.
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 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:
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 Jul 31
3
Polymorphic associations and single table inheritance
Running into an interesting problem that at first glance appears to be a
bug in the AR association code. However, it''s explicitly coded this way
so I''m not so sure.
I have some code like this:
class Address < ActiveRecord::Base
belongs_to :addressable, :polymorphic => true
end
class Person < ActiveRecord::Base
has_many :addresses, :as => :addressable,
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
2007 Mar 16
1
Polymorphic find_or_create bug
Today I just spent 3 hours (and before a demo!) trying to figure out
why my polymorphic association fields were breaking.
Turns out someone else put in a patch for this 6 months ago. I''m not
sure if its the same solution I''d use... I''d rather find_or_create
attempt to use AssociationProxy#build if its available and only
Base#new if we''re not on a proxy.
2002 Nov 18
0
NeXT Community wake up and smell the test cycle.
If no one replies soon on if this solves NeXTStep's incomplete mmap()
configuration then I will start ignoring all whining about that platform.
2007 Feb 13
10
Is there a limit on the size of a template?
Hello,
I have recently run across the following error:
/usr/lib/ruby/1.8/yaml/rubytypes.rb:315: [BUG] Segmentation fault
This has happened after adding a particularly large template file with ruby 1.8.1.
Thank you,
-- Rob --
____________________________________________________________________________________
Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews
2010 Feb 25
0
Bundle install error involving hash range errors
While running "bundle install" on a new Rails3.0.0.beta app on Ubuntu
9.10 / Ruby 1.8.7 with the following line in my Gemfile:
gem "mongoid", :git => "git://github.com/durran/mongoid.git", :branch
=> "prerelease"
I got the following error:
Installing mongoid (2.0.0.pre) from git://github.com/durran/mongoid.git
(at prerelease)
2012 Mar 02
0
ConnectionNotEstablished when using connection on AR::Base abstract subclass
I''m using AR outside of Rails and calling establish_connection on an
ActiveRecord::Base abstract_class subclass (to protect my connection
in case anyone else is using AR). It was working just fine with AR
3.0.9, but I recently attempted to upgrade to AR 3.2.2. Now, when I
hit a "nested" query from a has_many, I get a
ActiveRecord::ConnectionNotEstablished. If I call
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
=>
2006 Jan 11
0
Limit attributes written out by to_yaml
I want to write out a series of records to a text file so that I can
quickly edit them and then upload then again into the database. To do
this I am using YAML and some code that looks like this:
item = Item.find 153
File.open( ''item.yaml'', ''w'' ) do |out|
YAML.dump( item, out )
end
This dumps out all the field names and values which are stored in the
2006 Jan 31
2
How can I overwrite the parent.children.push(child) Method?
Hi all
I want to overwrite the push method (which is an alias of <<, the same
as concat) of collections, and there I want to test if :uniq is set to
true in the relationship. If so, the method should check if the passed
object is already related to the parent, or not (only then it will be
added).
But I just can''t find the original code of this method, so I could
overwrite
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)
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
2009 Jul 20
2
Hitting unknown error with "can't dup NilClass"
Hi,
My system has been encounter this problem, and I couldn''t find
solution after debugging. My scenario is stated below:
class user
has_many :posts
has_many :comments
end
class post
belongs_to :user
has_many :comments, :as => :commentable
end
class comment
belongs_to :post
belongs_to :user
end
For this case, I am trying to retrieve each post''s comment