similar to: Association extensions: how to access the object?

Displaying 20 results from an estimated 80000 matches similar to: "Association extensions: how to access the object?"

2011 Apr 16
0
adding HABTM association while creating a record
Hello Experts, I have a HABTM association as followed: class Account < ActiveRecord::Base has_and_belongs_to_many :user end class User < ActiveRecord::Base has_and_belongs_to_many :type has_and_belongs_to_many :account end class Type < ActiveRecord::Base has_and_belongs_to_many :user end I have the following query; I Have a parent user who is creating another user under its
2006 Feb 26
5
Help On Associations Extension.
Hi to all, I''m needing some help here ... I want to do an extension on a has_and_belongs_to_many to build a custom add method to the association. i have a table locations that has a many-to-many association with a tags tabel using a locations_tags table. i want to add a method to the Location has_and_belongs_to_many association so that i can do something like this on the location
2012 Sep 08
3
Polymorphic has_and_belongs_to_many association
Hi, I''m currently having the situation where I have to implement a polymorphic has_and_belongs_to_many by introducing an in between model that handles all the "has_many :as" and "belongs_to :polymorphic" association implementations... and is not doing anything else. Thing I don''t like it here is, I am unnecessarily loading AR instances only to execute SQL
2006 Jan 12
2
Finding by association
I have two objects that are associated in the following way: class Class1 < ApplicationController has_and_belongs_to_many :class2s has_and_belongs_to_many :otherClasses end class Class2 < ApplicationController has_and_belongs_to_many :class1s has_and_bleongs_to_many :otherClasses end Now, when I run the following query, @objects = Class1.find(:all, :conditions
2013 Jul 16
0
Which object have my association extension method?
My Stackoverflow question: http://stackoverflow.com/questions/17461273/where-does-association-extension-sit-in/17664817?noredirect=1#17664817 I have an association extension method like the following: class Bundle < ActiveRecord::Base has_many :items do def foo end end I was trying to use delayed job/sidekiq delay() method like the following: b.items.delay.foo But I
2009 May 31
0
[HELP] pagination w habtm association and authorization plugin...
I am using the proven authorization plugin to defines roles for users, so I can get all groups where a user is ''member'' @groups = current_user.group_memberships I have an habtm association between groups and events class Group < ActiveRecord::Base has_and_belongs_to_many :events .. class Event < ActiveRecord::Base has_and_belongs_to_many :groups I am trying to list
2006 Feb 10
0
Deleting the association entry for has_and_belongs_to_many when one object is destroyed
I know that for has_many, and has_one. I can do :dependent => true and the associated object will be destroyed when the main object is destroyed. However, there does not seem to be a dependent like option for has_and_belongs_to_many. Is there one I do not know of? Is there a simple solution to this? Thanks, Brian -- www.kenlet.com
2006 Jul 26
0
Using validators for appending to a HABTM association
class User < ActiveRecord::Base has_and_belongs_to_many :projects end class Project < ActiveRecord::Base has_and_belongs_to_many :users end class ProjectController < ApplicationController def add_user @project = Project.find(params[:project_id]) @user = User.find(params[:id]) @project.users << @user unless @project.users.include?(@user) # I''d
2006 Jan 06
0
bug rails activerecord association join
hi, I found a bug in ActiveRecord association SQL INNER JOIN codes. in has_many, has_one, habtm and belongs_to queries the foreign key is determined from the table name of reflection and self. but that''s worng because if you use a global prefix or suffix for your tables the foreign keys will be in format of PREFIX_CLASSNAME_SUFFIX_id which is wrong, because it breaks the advantage of
2011 Jan 14
0
[Rail3] How to construct full-text search for habtm associations
hi all, i''m new to this group and currently using Rails 3.0.3 and meta_where 0.9.10. i''m considering how to make a full-text searching feature to my project, and my models, for example, should be defined like below: class Group < ActiveRecord::Base has_and_belongs_to_many :users # :title (string) end class Comment < ActiveRecord::Base has_and_belongs_to_many :users
2006 May 18
3
Model Madness: habtm vs through
This has me scratching my head: a Person has many Things a Person has many Collections a Collection has many Things ...Things in a Collection are ordered ...Things in a Collection can be related to (created by) any User ...a collection has additional attributes, such as a name etc I am confused about habtm in rails (especially when using acts_as_habtm_list) vs. going the :through route.
2012 Sep 21
4
Good resource for the history of activerecord association method naming?
Someone asked me about the history of the method naming in activerecord and I wasn''t sure where to point them. For example, there was early criticism noted of has_and_belongs_to_many in this old post from 2005: http://hans.fugal.net/blog/2005/10/03/habtm/ I was mentioning that many_to_many is not used because there are a few different ways of doing that via has_many :through and
2007 Apr 04
4
Order a find using a has_many association
I''m trying to order a find through a has_many association. I have a model called SalesOrder. Each sales order has things like amount, description, etc. I use the following to get the Sales Orders: @sales_orders = SalesOrder.find(:all) And I display them with: <td><%= link_to sales_order.id.to_s, :action => ''show'', :id => sales_order.id
2006 Jan 06
6
HABTM problem not saving all associations
Hello all, I have an Order object that has and belongs to many Products and has and belongs to many Loan Types. This is so I can select multiples of each in my order entry screen via checkbox groups. I''m having some trouble with saving multiple HABTM associations for a single model object; only the first HABTM association declared in the model will save during the initial @order.save
2005 May 23
1
has_and_belongs_to_many dual insert error ?
Hi ! (See references at the end) I have a slight problem. Whenever I save one of my domain models, which contains an has_and_belongs_to_many relationship with another one, the relationships are doubled. My domain is a series of pictures, where each picture can be tagged with one or more words. So, a picture of my dog could be tagged "Jordy, Dog, Dog 2005", for example. In my
2005 Mar 01
0
has_and_belongs_to_many problem
I''m having a problem with a has_and_belongs_to_many (habtm) association between two models with extra attributes. I''m writing a comic book database, and each issue has many creators on it. Thing is, some creators perform multiple duties. They may write one issue, draw another, etc. However, if I add a creator twice to an issue and try to delete it, it removes both creators:
2006 Feb 20
0
How to reference a field of an associated object in a text_field
Hi, I hope someone can help, I am stumped. I have a Registration ActiveRecord object. It records registrations for people for classes. class Registration has_and_belongs_to_many :people has_and_belongs_to_many :scheduled_courses end I have a form that allows someone to register. A registration form will register two people. They fill in their names, addresses, and the classes they
2007 Mar 18
7
How to get more informations about an association at runtime
Hi all I''m working on a Custom Formbuilder. I want it to create me with a single method call checkboxes for a given HABTM association. My model looks like this: [code=ruby]class Member < ActiveRecord::Base has_and_belongs_to_many :preferred_music_styles, :class_name => ''MusicStyle'', :join_table =>
2006 Mar 19
1
some strange behavior for has_many with STI
Hi all, I''m having some trouble with a has_many association on a table using the single table inheritance model that I''m hoping someone can help me with. The schema for the table is: CREATE TABLE `comments` ( `id` int(11) NOT NULL auto_increment, `user_id` int(11) default NULL, `type` varchar(20) NOT NULL default '''', `type_id` int(11) NOT NULL default
2006 Aug 16
1
Naming rights_roles join model using has_many :through and polymorphic associations
Hi. I have a couple of best practices questions regarding polymorphic associations, naming join tables and user permissions. Currently I have implemented the user authentication model from the rails recipes book. Basically it goes something like this: MODEL CLASSES: class User < ActiveRecord::Base has_and_belongs_to_many :roles end class Role < ActiveRecord::Base