has-many Questions

5

Solved

I have three models: class Coupon < ActiveRecord::Base belongs_to :event has_many :coupon_events, :dependent => :destroy has_many :events, :through => :coupon_events end class Event ...
Presbytery asked 5/12, 2012 at 7:7

3

Here is an example: Let says I have a Student object which has a has_many relationship with ReportCard objects. ReportCard objects have a boolean field called "graded" that flags they have been gr...
Anglonorman asked 10/1, 2016 at 1:37

6

I have a Game model which has_many :texts. The problem is that I have to order the texts differently depending on which game they belong to (yes, ugly, but it's legacy data). I created a Text.in_ga...
Dieppe asked 14/8, 2012 at 9:57

2

I get the benefits of using eager loading to avoid N+1 when fetching an array of objects with their associated records, but is it important to use eager loading when fetching a single record? In m...

1

I'm new on laravel. Why I'm always get error: array_map(): Argument #2 should be an array ? whereas I'm assigning parameter array on this method? this is my example code : $products = Catego...
Auricle asked 9/11, 2015 at 8:57

4

I just ran into an interesting situation about relationships and databases. I am writing a ruby app and for my database I am using postgresql. I have a parent object "user" and a related object "th...

2

Solved

I'm trying to customise a ActiveAdmin form for a Recipe model that has a has_many relationship with Step. class Recipe < ActiveRecord::Base has_many :steps end class Step < ActiveRecord::B...
Steele asked 26/8, 2011 at 14:52

1

Solved

I try to create a polymorphic association, what is common in Rails but unfortunately not in Yii2. As part of the implementation I need to define the relation: public function getImages() { retu...
Vocative asked 28/5, 2015 at 10:3

2

I use paper_trail in rails to track my models versions. But the documentation on the github repo indicates that the gem doesn't support has_many, belongs_to associations. Let's say I've an app tha...

2

I am using Ember.js with local-storage-adapter. I have a weird problem while updating records. I have a post and comments model with hasMany relationships: App.Post = DS.Model.extend({ title: D...
Disheveled asked 26/10, 2013 at 7:40

4

Solved

I am new to Ruby on Rails. I have a problem- how to get only latest records from has many relationship in model. My code is like this: class User < ActiveRecord::Base has_many :books end cla...
Malicious asked 28/3, 2015 at 19:57

3

Solved

Users can add tags to a snippet: class Snippet < ActiveRecord::Base # Relationships has_many :taggings has_many :tags, :through => :taggings belongs_to :closing_reason end I want to ...
Kerby asked 29/1, 2011 at 12:34

2

Solved

I've got the following models associated with sequelize. Event hasMany Characters through characters_attending_boss Boss hasMany Characters through characters_attending_boss Characters hasMany Eve...
Contributory asked 14/10, 2014 at 14:10

3

Solved

In rails 3, i know that i can force deletion of dependent objects on belongs_to and has_many relations using the :dependent => :delete option. However i was wondering, what is the default behavio...

3

Solved

I have 3 tables - users, things, and follows. Users can follow things through the follows table, associating a user_id with a things_id. This would mean: class User has_many :things, :through =&g...
Henke asked 16/1, 2012 at 0:42

2

Assuming class Kid < ActiveRecord::Base has_one :friend end class Friend< ActiveRecord::Base belongs_to :kid end How can I change this to class Kid < ActiveRecord::Base has_many :f...
Ushijima asked 13/8, 2014 at 4:7

2

What is the ember-cli best practice to deleteRecord() on a model that belongsTo multiple models? Do I have to manually clean up relationships on the parents? Migrating from ember to ember-cli I am...
Gallous asked 9/7, 2014 at 3:24

2

Solved

Im trying to create a computed property to get me the sum of the length of all pages. But i cannot figure out how to access a child so i can get the childs of that child. App.Document = DS.Model...
Myel asked 11/4, 2013 at 14:20

1

Solved

I have two models for Show and Performance (show as in a play or comedy show). They are associated like this in the models: class Show < ActiveRecord::Base has_many :performances, :dependent =...
Why asked 5/6, 2014 at 20:41

2

I am trying to save objects having Many-Many Relationship . A SellingCompany can have many Accounts and an Account can be associated with many SellingCompanies. So there is a many-many relationship...
Evaginate asked 15/3, 2011 at 17:40

2

Solved

I have Questions table which have store so many question. Question related to question_topics so have create has many relationship with question. Now it's look like this: $this->Question->bi...
Hawking asked 24/4, 2014 at 12:13

1

Solved

I'm looking to DRY up my test suite. Trying to create a trait that represents specific values of a has_many relationship on the parent factory. Ideally these values would be created from a separate...
Misreport asked 25/3, 2014 at 2:5

2

Solved

We have an old application where the relationship is defined as below: class Practice { String name static hasmany = [doctors:Doctor] } and class Doctor { String name } There is not a belo...
Eyra asked 20/3, 2012 at 16:9

1

Solved

I have problems with has_many / has_many relationship using nested form for the following case. I have articles and this can have many units (Kg, bags, etc). And through my form I need to record t...

3

I have something like the following: class Project < ActiveRecord::Base has_many :project_people has_many :people, :through => :project_people end class Person < ActiveRecord::Base ha...
Renwick asked 14/7, 2011 at 14:38

© 2022 - 2024 — McMap. All rights reserved.