has-many Questions

1

Solved

Two models: class Task < ActiveRecord::Base has_many :subtasks end class Subtask < ActiveRecord::Base belongs_to :task end Subtask have boolean attribute that set to true if subtask i...
Lalalalage asked 28/3, 2012 at 18:22

3

Solved

A User has_many Solutions How do I order Users by those with the most Solutions? I'm trying to find the top ten users but I'm not sure how the most tidy or efficient way to do this? Does anyone...
Gaudy asked 16/3, 2012 at 14:49

2

Solved

I have a User model which has many projects and a Project model which can have many users, but also belongs to a single user (ie the user who created this project). It must belong to a User. It als...

3

Solved

I am analysing the rails source code, because I wold like to understand the inner workings of the has_many and similar constructs. So far, I was able to find where the method is implemented (link ...
Washcloth asked 25/2, 2012 at 22:53

1

Solved

I need to track changes (additions and deletes) of an association set up like this: has_many :listing_services has_many :services, through: :listing_services For normal attributes the easist way...
Ammonate asked 21/2, 2012 at 18:3

1

I am following OmniAuth railscasts and trying to implement the same with authlogic + facebook instead of devise + twitter as shown in the railscast. Maybe my understanding of has_many still isn't g...
Furring asked 2/6, 2011 at 18:52

1

Solved

ActiveRecord proxy_owner is now deprecated and the explanation here is very vague on how to change it, so I'm not sure how to use it my case: http://apidock.com/rails/ActiveRecord/Associations/Ass...
Partan asked 9/8, 2011 at 19:27

3

Solved

I have a simple rails app with models project and phase. A project has many phases, but only on phase can be active (i.e. "current") at a time. I still want the other phases to be accessible, but t...
Uproar asked 11/7, 2011 at 10:28

1

Solved

I have a domain class which has many of another domain class. I want any one of the children and don't care which. Example class MyDomainClass { static hasMany = [thingies:OtherDomainClass] } I...
Juncaceous asked 27/6, 2011 at 21:44

3

Solved

Ok so currently I have a form <div class="field"> <%= f.label :title %><br/> <%= f.text_field :title %><br/> <%= f.label :itunesurl %><br /> <%= f....
Whitmore asked 13/5, 2011 at 18:45

3

Solved

I have the following line in my ActiveRecord model: class Record < ActiveRecord::Base has_many :users, :through => :record_users, :uniq => true, :order => "record_users.index ASC" T...
Eijkman asked 11/11, 2009 at 11:56

1

Solved

I have a model like this class Canvas include Mongoid::Document field :name referenced_in :hero end class Browser < Canvas field :version, :type => Integer end class Hero include Mong...
Repurchase asked 30/3, 2011 at 6:12

1

Solved

I got some Manager and SoccerTeam model. A manager "owns" many soccer teams; also a manager can comment on soccer teams and can comment on other managers too: manager.rb # Soccer teams the manage...

1

Solved

def destroy @dignity.destroy end Sorry, that's not code, that's just how I feel right now. I know there are a ton of beginner questions on Devise, I think I looked at almost every single one. ...

1

Solved

I have a: has_and_belongs_to_many :friends, :join_table => "friends_peoples". To add a friend I do: @people.followers << @friend which create the relationship and a new person profile. N...
Catania asked 3/10, 2010 at 23:37

3

I'm a Grails noob and running into something that seems to be a bug, but it is entirely possible I'm not configuring everything correctly. I've got two simple Domain Classes: class Player { St...
Renfred asked 5/5, 2009 at 3:6

3

Solved

I want ActiveRecord to lookup by a non-id column from a table. Hope this is clear when I give you my code sample. class CoachClass < ActiveRecord::Base belongs_to :coach end class Coach < ...

3

Solved

how I can get the has_many associations of a model? For example if I have this class: class A < ActiveRecord::Base has_many B has_many C end I would a method like this: A.get_has_many t...
Sapota asked 21/5, 2010 at 8:36

3

Solved

I have class MyContainer < ActiveRecord::Base :has_many MyObjects, :dependent => :destroy end I want to delete all the MyObjects in the container without having to delete the MyContainer....
Millais asked 20/4, 2010 at 7:4

2

Solved

Hy, My code: @profile.images and i would like to get only 10 images at time and with a 10 offset, like this @profile.images(:limit => 10, :offset => 10) and not like this has_many :im...
Dynamotor asked 30/3, 2010 at 16:3

1

I am running in to a problem while using find_or_create_by on a has_many through association. class Permission < ActiveRecord::Base belongs_to :user belongs_to :role end class Role < Acti...
Impatience asked 9/2, 2010 at 21:36

3

Solved

I have a model, Couple, which has two columns, first_person_id and second_person_id and another model, Person, whose primary key is person_id and has the column name Here's the usage I want: #inc...
Pardner asked 24/1, 2010 at 0:57

3

Solved

I have a has_many relationship between two entities, Feeds and Posts. I also have specific types of posts, Videos and Photos. This is structured in the database using single table inheritance. Rig...
Permatron asked 20/5, 2009 at 17:37

2

Solved

Suppose the following data schema: Usage ====== client_id resource type amount Billing ====== client_id usage_resource usage_type rate In this example, suppose I have multiple resources, each o...
Leu asked 11/11, 2008 at 1:47

4

Solved

A bit of a newbie question on rails associations. I have a Bug model, and a Status model. Status is basically just a key/value pair table. Out of the choices available, I would say Bug has_one Sta...
Loge asked 22/5, 2009 at 21:0

© 2022 - 2024 — McMap. All rights reserved.