similar to: Patch to provide has_one :through functionality (ticket 4756) - eyeballs required

Displaying 20 results from an estimated 10000 matches similar to: "Patch to provide has_one :through functionality (ticket 4756) - eyeballs required"

2012 Nov 19
0
has_one :through NoMethodError: undefined method `klass' for nil:NilClass when doing class_name on reflection
Not sure if this is expected or not. Only happened with a has_one :through I had setup. (Workaround is just to remove it and go through the association manually vs has_one ..., through: .) Not a big deal if no one has time to look at it, as it''s not a big enough deal to look into a fix on our side. In Rails (3.2.9) console if I do: MyModel.reflections.each {|name,reflection|
2007 Dec 06
0
has_many :through with a has_one source
Here is my simple example... require ''rubygems'' require ''active_record'' ActiveRecord::Base.establish_connection :adapter => "sqlite3", :database => "has_many_through.db" ActiveRecord::Schema.define do create_table "containers", :force => true do |t| t.column :name, :string end create_table "shapes",
2006 May 12
1
can I fake has_one :through?
I''m having a difficult time wrapping my head around a set of models and their associations and seeing how they map into Rails. I''ll try to lay out my problem using the has_many and belongs_to structures. I have a RuleSpace, a Rule, and a Subject. A RuleSpace has_many Rules A RulesSpace has_many Subjects through Rules A Rule belongs_to (many) RuleSpaces A Rule has_many
2008 Feb 19
0
Issue with Observers and has_one association...
Hey Guys, I''m getting a peculiar bug working with Observers and has_one associations. When a has_one association is invoked by an Observer it always returns null. I looked in the development.log file and the SQL for the has_one association isn''t even being executed. On the other hand, when I replace the has_one association with just a hand crafted method, it does get called
2007 May 14
0
building and saving has_many and has_one relations
Hi, I am very confused about an aspect of has_one and has_many relations, with regard to using the build method, and saving the belongs_to side. It''s a somewhat long post. so please bear with me :) First let''s consider the has_one scenario. Let''s say I have a student who must own exactly one car: class Student has_one(:car) end class Car belongs_to(:student)
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
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 Jul 07
0
has_one through belongs_to
Hi. My model data is the following: - Place - User - Checkin Instead of having a Checkin that belongs to both User and Place, I chose to add another model, Program, that allows to list all the places a user can checkin into, and also hide the checkins he''s no longer involved in (= the user sign out of a specific program). That give me crazy relationships: Program has_many Checkin
2005 Oct 27
0
has_one with Single Table Inheritance - NameError : uninitialized constant
I am having a problem with using SIngle Table Inheritance with a has_one relationship, and I am at a loss of what could be causing it. Below is the related code and the error message. class User < ActiveRecord::Base has_one :wishlist end class List < ActiveRecord::Base belongs_to :user end class Wishlist < List has_and_belongs_to_many :items, :class_name =>
2006 Jun 19
0
has_one frustrations, please help!
Hi everyone. I''ve been bending my head around a has_one association for about 3 hours now and I can''t get it to work. I''m pretty sure it''s not something I''m overlooking anymore. Here''s the essential part of the schema I''m working with: ----- t :topics c :id c :last_post_id t :posts c :id c :topic_id ----- Topics are simply named
2007 Aug 03
0
acts_as_paranoid and Association Extensions (has_one troubles)
Hi... Isn''t there a proper way or hack/workaround for the following? * For the example with unfortunate disabilities.. look below,,, Usage of has_* (associationmethods) do {def with_deleted AccociatedModel#with_scope} {Paranoid''s#find_with_deleted}... The has_one associations give me a nil object when invoking it with Model.association_OBJECT.with_deleted. Has_many does like
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 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
2007 Mar 01
0
association extensions - has_one
Hi, I''m struggling with something that must be very common pattern, and want to do it the correct rails/ruby way but am a bit dense ! I have users - an admin user, registered users and a guest user (using ModelSecurity) For many of linked associations I want the admin to be able to list or edit all instances, the registered user only their own one and guest none at all. So somehow I
2006 Jul 17
2
Trouble with has_one
Hi, I''m trying to write a blog application where each post has a single header image associated. My models: ---------- class Post < ActiveRecord::Base belongs_to :blog has_many :images has_one :header end class Header < ActiveRecord::Base file_column :image_path end class Image < ActiveRecord::Base belongs_to :post file_column :image_path end The controller targets I
2006 Feb 20
1
belongs_to, has_one, has_many question (again?)
Hi All, Probably this has been asked numerous times, I apologize already! Can somebody point me to a good tutorial on how Rails works with relations? I know about database design and normalization, I also know about programming in general (and OOP for that matter). Only thing I can say is that I''m following the "Four days on Rails" tutorial by John McCreesh. He writes
2006 Nov 04
0
one to many relationship; has_one
I''m new to ruby and rails and as a result am a bit lost on implementing a one to many relationship. In my DB I have 2 tables contents and locations, contents contains the foreign key location_id. I generated a content and a location model using rails scripts and then edited the models as follows class Content < ActiveRecord::Base has_one :location end class Location <
2006 Jan 26
0
setting default on "has_one" failure
Hi there, I have a model for a Film, which: has_and_belongs_to_many :artists has_many :stills has_one :preview_image, :class_name => "Still", :conditions => "priority=''main''" the has_one:preview_image and has_many:stills obviously draw from the same table. I was
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 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