similar to: associations help?

Displaying 20 results from an estimated 11000 matches similar to: "associations help?"

2008 May 03
11
Date comparisons
I occasionally get this error: 1) ''A puzzle once featured, should no longer be nominated'' FAILED expected: Sun May 04 09:10:26 -0700 2008, got: Sun May 04 09:10:26 -0700 2008 (using ==) ./spec/models/puzzle_spec.rb:180: So, the dates looks the same to me. Any ideas for how to debug? Joe
2006 Dec 22
2
Relating Namespaced Models
I am dealing with a large project. I use a lot of STI and therfore have a lot of models. I''d like to use namespaces to help organize my models but am having trouble getting started. I have a base model Term::Base located in /app/models/term/base.rb: class Term::Base < ActiveRecord::Base set_table_name "terms" end I have a non-namespaced client model: class Client <
2008 Jun 13
6
Newbie question on has_many
I have two classes: a Widget and a User. The User has an id that is referenced in two places on the Widget: owner_id and operator_id. How should I structure that reference for has_many? Thanks folks - I appreciate any help on this. --David --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2006 Mar 03
2
Through relationship
I am working on streamlining one of my apps, and trying to wrap my hands around through, polymorphic, and with_scope. All of these i know i need for what i want to do, based on the little documentation I have found. With this in mid I have tried to implement a simple through in the app to try and get my head around it. This is what I have: class Product < ActiveRecord::Base
2010 May 14
4
Tricky model situatione
I have two models Club and users. users are regular authenticated users and some of them might create a club. A club can also have members (essentially users) and there are attributes and models that apply to member but not to users. Here is what I have right now. Club => belongs_to :user User => has_many clubs (since a user can host multiple clubs). Now how do I fit this member model
2006 Jul 03
4
Display find(:include => [:children]) results in a view
I am trying to determine how to display a list returned from a Rails find(:include => [:children]). I am using the following (which works in the console): @patients = Account.find(session[:account_id]).patients.find(:all, :include => [:patient_details]) How can I address the patient_details to display them in the view? The console even shows a @patient_details instance variable
2006 Apr 06
4
Record retrieval in Many-to-many using :through not working
Hello, I get an error while retrieving records from the following model structure. Tables foods - id, food foodallergies - food_id, symptom_id, a few other columns symptoms - id, symptom Models class Food < ActiveRecord::Base has_many :foodallergies has_many :symptoms, :through => :foodallergies end class Symptom < ActiveRecord::Base has_many :foodallergies has_many :foods,
2006 Jun 22
11
Help please
Getting this error: SyntaxError in CompanyController#positionslist (eval):1:in `compute_type'': compile error (eval):1: parse error, unexpected tINTEGER Object::2 I could not find anything out about it (googling) and it''s not the clearest error message. Not sure if it''s related to an expected data type but that wouldn''t make sense. The only other thing I can
2006 Jan 17
9
using "find" when you have 2 has_many relations
An Account has_many Websites which in turn has_many WebsiteDomains Now I can of course do this: @domains = Account.find(1).websites.find(1).website_domains.find(:all) To get all the domains for Account with id 1 and Website with id 1. I would like to do something like this though: @domains = Account.find(1).websites.find(:all).website_domains.find(:all) IE, get ALL domains for all websites in
2006 Dec 13
3
Testing has_many :through
I''m working with a has_many :through association, where a Member has_many Projects through ProjectViewers. The problem I''m running into is that Rails doesn''t load the association so line (3) fails until I explicitly access a member of the collection (in this case, I iterated it). Is there a better way? Thanks, Steve 1. assigns[:member].should_not_be_nil 2.
2010 Aug 02
7
Complex associations
I am working on a project that has some complex table associations, and I am having a hard time declaring this association in a Model, and fear it can''t be done. Here is an example of my issue... class StoreType < ActiveRecord::Base; end class Store < ActiveRecord::Base; end class Department < ActiveRecord::Base; end class Product < ActiveRecord::Base; end A StoreType has
2006 Dec 05
4
has_many with :uniq not working for me
Hi all, I have a relationship (no really!) class RiskMatrix < ActiveRecord::Base has_many :severities, :order => :position, :uniq => true end class RiskFactor < ActiveRecord::Base belongs_to :risk_matrix validates_presence_of :descriptor, :example validates_uniqueness_of :descriptor, :example, :scope=> :risk_matrix_id end class Severity < RiskFactor
2006 Jan 05
3
has_one :dependent => true question
Hello, I have two classes that are self explanatory and are listed below. class User < ActiveRecord::Base belongs_to :account end class Account < ActiveRecord::Base has_one :account_owner, { :dependent => true, :class_name => "User", :conditions => "is_account_owner = 1" } has_many :users end In the signup controller when an account is created one user
2008 Jul 16
2
belongs_to causing endless loop on first call to save!
Hi, I have a situation I''m hoping someone out there may be able to shed some light on. I have a Rails app (2.1.0 on Ruby 1.8.7) with a wizard-based sign up process, that has recently been changed from storing incremental data in the database to having a medium sized object graph living in the user session until the user completes the entire sign up process (this is a business
2006 May 20
7
Polymorphic, many-to-many, self-referential data model
No matter what I try I''ve been unable to work how to get this to work with the cool ActiveRecord helpers. I''m not sure if it''s possible, Josh Susser''s blog suggests it is, but damned if I can work it out... I have: Container which can contain one or more Element. An Element is a polymorph of either a Container or a Chunk. An Element can exist in one or more
2009 Feb 02
9
ActiveRecord Unexplainable SystemStackError - Only in WEBrick
This SystemStackError is driving me crazy. It only takes place when testing with WEBrick - I can''t reproduce it with any tests. It is caused by calling the "missing" id method (base.rb:2435) on my ActiveRecord class. WEBrick and my tests are running as the same user, with a `ulimit -s` of 10240. Plus the query works sometimes so I don''t think this matters.
2011 Jul 11
2
Pre-populating association
Hello, I think this is an easy one for the average Rails developer but I''m a bit stuck. I''m creating a simple voting app: any user can create a survey, with any number of questions, and other users can then vote by creating a ballot for that survey. Here''s the modeling: class Survey < ActiveRecord::Base has_many :questions has_many :eligibilities has_many
2006 May 09
5
Shared Queue / Exclusive Query Results
My application is going to have a work queue of scheduled tasks stored in the DB. This work queue will be shared across multiple Rails app servers. I need a way to ensure that no two servers get the same jobs if multiple servers pop jobs off the top of the queue simultaneously. Is there a fairly simple way to acheive this? Or do I need to come up with some fancy secondary server to dispatch
2011 Jul 14
10
Devise confusing routes
I had a similar problem yesterday. I would go to the root of my site and I would get a Too Many Redirects message. It seems like there was an infinite loop. After struggling for over an hour yesterday late at night, it seemed like I fixed it. But now, when I want to create a New User, it''s redirecting me to the Sign In screen. Seems like I didn''t fix the problem completely. I
2013 May 22
3
rails 4, active record: appending to has_many :through does not create join model anymore?
hi folks. on rails 4, can somebody confirm that pushing model instances onto a has_many :through relation does not create the necessary join model anymore? class Reader < AR::Base belongs_to :post belongs_to :person end class Post < AR::Base has_many :readers has_many :people, through: :readers end @post.people << Person.new so,