similar to: has_many relationships and minimums

Displaying 20 results from an estimated 10000 matches similar to: "has_many relationships and minimums"

2006 Aug 16
0
Testing has_many, :through relationships
Hi All, This is my first post on this list. I''m a developer working on the Central Coast of NSW, Australia and came across RSpec via Lachie who demoed RSpec on Rails at a Sydney rails user group meeting a couple of months ago. I''m loving the expressiveness of RSpec and can''t really see myself going back to Test::Unit. I''ve come across one oddity though. I
2005 Nov 09
0
Sorting has_many relationships
Hi Railers! I''m building a new website for our bar-foos-league (league for foosball players who play in bars in Zurich, Switzerland ;-) Being a bit of a noob when it comes to rails and web development in general, I''ve come across a few questions. One concerns sorting of a has_many relationship, for instance. I''ve got a League model, which has_many TeamConfigs
2006 Jun 07
2
destroy on has_many relationships.
i need to delete a record from the database and delete all of it''s children as well. is there a method for this? right now, i am finding all the children with the parent_id and destroying them first and then destroying the parent. seems like there would be a better way to do this but i can''t seem to figure it out. thanks, josh -- Posted via http://www.ruby-forum.com/.
2006 Sep 14
1
acts_as_ferret with has_many :through relationships?
I am currently using acts_as_ferret to search on a Posts table (title and content fields). These posts also have tags (with has_many :tags, :through => :questions_tags). I can''t figure out how to get acts_as_ferret to work with that relationship and allow searching of title, content, And tags at the same time (with the ability to set boost as well). Can this be done? -- Posted via
2006 Apr 05
3
CRUD pattern for has_many relationships (forms containing collections)?
Hello folks! Beare with me for a second, while I explain my problem. Assuming we have the trivial model of class Author has_many :books end class Book end How do people go about creating the authors/edit and authors/new views if you want to be able to add and remove arbitrary amount of Books at Author creation and edit time? What I mean by this is that I go to
2006 Apr 20
4
Many to Many Category structure with itself
Basically, I''m trying to have a table called "categories" have a many to many relationship with itself. But I also want each catagory to be able to be "copied" into another category so it is essentially a child category to more than one parent. To me the obvious way of doing this is by creating another table called category_maps (and a model called CategoryMap).
2005 Dec 27
0
How do I combine :finder_sql and :conditions to perform a sub-search on a custom has_many relationship?
I''m sure there''s something right under my nose that I''m missing. I have two tables with two parallel one-to-many relationships. I wish to use the :finder_sql parameter to essentially ''or'' the two foreign keys. What isn''t working for me is performing a ''sub-search''. Let''s say the tables are "stores" and
2005 Dec 26
2
Dynamic order on has_many relationship?
I was wondering if it''s possible to some how control the :order given on a has_many depending on another attribute? Or do I need to just create multiple has_many relationships pointing to the same table but with different orders and then select which one I use in the controller instead? e.g class Category < AR::B has_many :products, :order => //something magical?// end
2006 Apr 22
0
Re: CRUD pattern for has_many relationships (forms containin
Hi Christos, I''ve seen you message in the mailing list archive and I''m trying to achieve the same behaviour. Did you progress in your knowledge of the problem this you last posted? It seems the mailing list hasn''t been that helpful to you. Maybe we can work out a solution by us two. Cheers, gilles
2006 Aug 18
1
uninitialised constant?
Hi. I''m having problems with a class constant I''ve defined as follows: class Customer < ActiveRecord::Base has_many :orders TITLES = [''Mr'', ''Ms'', ''Miss'', ''Mrs''] end Whenever I try and access this constant using Customer::TITLES, I get an unitialized constant Customer::TITLES error. Is my syntax
2010 Jan 08
1
problem using build with has_many :through relationship
Hello all, I''m having problems creating a new record with has_many :through My application is quite complicated so I''ll try to explain it as easy as I can. I have a many to many relationship with Projects, IRBs and Reviews. Where reviews is the joined model. In the new project view, I have a link (add IRB). This will add an a list of IRBs to the new project form. I have visited
2011 Jun 22
0
has_many relationship in Gem
Hello, I am creating a gem in which I need to add a new has_many relationships: ... included do |base| base.has_many :foos end def some_method self.foos # end ... Here Foo is a model I created and it is places in app/models/Foo.rb I wonder if I can use syntax like the line marked with #? If yes, I got NoMethodError for using "self.foos" when writing rspec
2006 May 28
7
Self-referential has_many :through relationship
Hi, I have a self-referential has_many :through relationship setup to track relationships between users. Basically relationships are modeled as a join table with an extra column ''relation''. create table relationships ( user_id integer unsigned not null, friend_id integer unsigned not null, relation char(1) not null, ) --- relations --- f = friend r = request to
2006 Jul 03
0
Modelling Relationships as objects
DHH in Rails Confeerence pointed out that abstract relationships should be converted into concrete objects, CRUDying up relationships. An example would be class User < ActiveRecord::Base has_many :subscriptions has_many :news_categories, :through => :subscriptions end class NewsCategory < ActiveRecord::Base has_many :subscriptions has_many :users, :through => :subscriptions
2011 Jan 15
3
has_many :through with Single Table inheritance
I have the following model structure setup. class User < ActiveRecord::Base end class Parent < User has_many :relationships has_many :children, :class_name => "Student", :through => :relationships, :conditions => "related_as = ''parent''" end class Student < User has_many :relationships
2008 May 27
2
HABTM using two columns
Hi all, I was wondering whether anyone could guide me to docu and code examples how to create and use a has_and_belongs_to_many relationship with a joining table where TWO columns are used to identify the relation to TWO alternative tables. Example: table 1: mothers [mother_id, name] table 2: fathers [father_id, name] table 3: children [child_id, name] joining table 4: children_parent
2005 Apr 27
4
has_many syntax
Hi all, I have the following inside of an AR class definition: relationships=ActiveRecord::Base.connection.select_all(my_relationships_sql) relationships.each do |relationship| has_many RelatedItems, :class_name => relationship[''RelatedClass''], :foreign_key => relationship[''ForeignKey''] end This kind of works, but how can I assign the name of the
2007 Oct 22
1
self-referential habtm: why are my keys null?
I''m trying to set up a directional self-referential HABTM to represent an arbitrary semi-hierarchical structure; it works for any data prepopulated into the db, but when I try to create a new relationship, I just get NULLs in both key columns (or 0''s if I turn on the no-null constraint). Here are the migrations: class CreateNodes < ActiveRecord::Migration def self.up
2006 Jul 04
1
Has_many :through with checkboxes?
Just when I started getting the hang of has_and_belongs_to_many relationships, I realize that I should probably convert several of my app''s joins to has_many :through type relationships. One example, pairing users with categories via subscriptions, where each user can be the "owner" of a category, has given me particular trouble when I try to update a user''s
2006 May 07
1
Anyone care for a braindump?
I have this problem with records that have to be alligned on end- and startdate. I came up with the following. but am not convinced that this is the best way to tackle this problem. Anyone care for a braindump? def head_to_tail # Remove days that have startdate >= self.startdate AND enddate <= self.enddate # # before after # # |=====| |=====|