similar to: Removing an association from a derived class

Displaying 20 results from an estimated 30000 matches similar to: "Removing an association from a derived class"

2010 Mar 19
3
Ruby on Rails tutorials for beginners are available here
Hello Everyone, I have started my blog at http://railsguru.org. Besides other stuff on Rails, the main focus of the site will be to help beginners to learn Ruby and Rails and build the fundamentals. Regards, Pankaj Bhageria, Tech Lead, Sumeru Software Solutions. http://www.railsguru.org http://www.sumeru.com -- You received this message because you are subscribed to the Google Groups
2006 Apr 19
2
Using Reflections to find out ActiveRecord class association
I want to find out what are the associations with another active record class. So If my class is as below: Class Component < ActiveRecord::Base has_many :branches end class Branch < ActiveRecord::Base belongs_to :component end and then I do Component.reflections[:branches].active_record I would expect that to be Branch but it is in fact Component. The inspection of
2008 Feb 13
1
can a class have the association has_itself?
is it possible to implement a recursive foreign key association like that? i''m writing a vocab app, where i want the vocab table to have an id and two foreign keys, word1 and word2. the word table will have an id, a word-string, and a language i''m trying to do this as follows: class Vocab < ActiveRecord::Base belongs_to :word belongs_to :word class Word <
2008 Jan 11
2
Virtually deleting rows from tables
I dont want to delete the records from my tables but just set a column is_deleted to true. What is the best (clean)way to implement this? Is there any way of defining a model which includes only a set of records which satisfy a certain conditions.eg a condition to include the records for which is_deleted is false some thing like this def User << ActiveRecord::Base :conditions=>
2006 Jun 07
1
Calling find on AR class, order by association count?
I suspect that this is going to wind up trivial and I''m going to slap myself in the head... Suppose I have User and Comment AR classes. User has_many :comments, Comment belongs_to :user I want to do a User.find, which returns User objects in order of which user has the most comments. I suspect that this involves renaming the COUNT(*) results of a sub-select so that I can order by
2006 Jul 26
3
Polymorphic Association with Single Table Inheritance?
Hello, is it possible to setup a model/table schema like this: Groupable --> Membership <-- Group ^ ^ | | User UserGroup I tried the following but failed: Groupable (table with ''type'' column) has_many :memberships, :as => :groupable has_many :groups, :through => :memberships
2006 May 08
2
Creating a "Foo has_many bars" association where bar isn''t a model.
Hi Let''s say we have model Foo. Each Foo instance can have several bars. Those bars are primitive, so they shouldn''t be models. For example, Foo might be a type of convention, and the bars might be years the convention was held in. Naively, we would have a conventions_years date, and put: has_many :years inside class Convention. But then we''d get an error, since for
2006 Aug 03
12
More than one has_many :through association between the same 2 models
I wonder if you can have more than one has_many :through association between 2 models. For example... I have a model Teacher and a model Class Now, 1 Teacher works in many Classes, right?. So I need a join model like class Work < ActiveRecord::Base belongs_to :teacher belongs_to :class end But I also would like to know if a teacher CAN teach a class before I
2011 Nov 02
2
Specify and validate requirements on an ActiveRecord association
Looking for some guidance/support on what feels like might not be an uncommon use-case. `User.has_many accounts` `User.has_many payment_methods` `Account.belongs_to :user` `Account.belongs_to :payment_method` `PaymentMethod.has_many :accounts` There are lots of `Accounts`. When I (a `User`) want to assign accounts to a `PaymentMethod`, I really don''t want to scope against all of them,
2007 May 22
3
can I use acts_as_list with a has_many :through association
I''d like to be able to use a has_many :through association and treat the associations as a list but I''m getting this error when I try an use an acts_as_list method: NoMethodError: undefined method `move_to_bottom'' I''m using edge rails r6786. Here are my domain rules: Activities are things students can do. Units consists of a sequenced list of
2006 Jun 19
3
Strange behavior of :through association.
class Host < ActiveRecord::Base belongs_to :person end class House < ActiveRecord::Base has_many :people, :dependent => true has_many :hosts, :through => :person end class Person < ActiveRecord::Base belongs_to :house has_many :hosts, :dependent => true end Now when I try to do: @hosts = House.find_by_id(params[:namas]).hosts from my controller I get this:
2013 Jul 21
4
how to use activemodel collection.build for a has_many :through association
Hi all, In my controller I am doing the following to populate a nested form for a has_many through association: def new @specification = Specification.new Component.find_each.each do |component| @specification.component_specifications.build(:component_id => component.id) end The idea being whenever someone creates or edits a form, it will be populated with all
2008 Nov 19
3
Overwriting / Decorating ActiveRecord association accessor
Hi, I am trying to overwrite the accessor of a has_many association. Basically my class looks like this: class Person has_many :emails has_one :link, :class_name => ''PersonProxy'' def emails_with_link link.emails + emails_without_link end alias_method_chain :emails, :link end Now that works fine if I only access the collection like >>
2009 Aug 05
1
[PATCH server] associated nics w/ network base class as it is in the db
fixes regression bug that got recently introduced --- src/app/models/network.rb | 2 ++ src/app/models/physical_network.rb | 2 -- src/app/models/vlan.rb | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/app/models/network.rb b/src/app/models/network.rb index a4b1b8b..89f9876 100644 --- a/src/app/models/network.rb +++
2009 Aug 28
2
Association extension method
In my application a user working at a dropzone can manipulate transactions against customer accounts. Here''s my models: class Transaction < ActiveRecord::Base belongs_to :account end class Account < ActiveRecord::Base belongs_to :dropzone has_many :transactions end class Dropzone < ActiveRecord::Base has_many :transactions, :through => :accounts do def
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
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 Feb 17
1
validate() with has_many association
I''m creating a simple portfolio site for a painter. I have a painting and an image model with following relationship: Painting has_many :images Image belongs_to :painting On the edit screen the user can edit the Painting data as well as upload pictures for a thumbnails and full size image. The Image model extracts filename, width, and height from the uploaded file, saves those
2006 Mar 31
6
Adding objects to a :through association
So I''m one of those nasty people building a self-referential habtm-like Association using the funky new :through stuff. This is about users having friends, so here''s my user.rb: class User < ActiveRecord::Base has_many :friendships, :foreign_key => ''user_id'' has_many :friends, :through => :friendships, :source => :friend end And here''s
2010 Aug 29
4
Wrong class being returned in association
I''m using Rails 3.0.0rc and have the following models: class User  has_many :readings  has_many :conversations, :through=>:readings end class Reading  belongs_to :user  belongs_to :conversation end class Conversation  has_many :readings  has_many :users, :through=>:readings end and this controller code: class ConversationsController  def show    @user =