model-associations Questions
2
I am creating association pretty much identical with the Rails Guides Patient-Appointment-Physician data model. A user has many prospects through prospect_subscription. However, when trying to acce...
Undertook asked 10/1, 2022 at 9:25
8
Solved
I want to be able to use two columns on one table to define a relationship. So using a task app as an example.
Attempt 1:
class User < ActiveRecord::Base
has_many :tasks
end
class Task <...
Colonial asked 8/7, 2014 at 21:38
8
Solved
I have been (hours) trouble with associations in Rails. I found a lot of similar problems, but I couldn't apply for my case:
City's class:
class City < ApplicationRecord
has_many :users
end
...
Fielding asked 16/8, 2016 at 20:13
1
Solved
I've found a bunch of articles, stackoverflow answers and rails documentation about 'source:', but none of it explains this association in a way I can understand it. I need the most simplified expl...
Contravene asked 25/4, 2020 at 17:51
2
Solved
I am learning cakePHP 3.0 and have some problem with saving associated data on my model.
I try to save a Client with associated data of ClientPreferences
ClientTable
class ClientsTable extends T...
Uncourtly asked 15/4, 2015 at 16:4
2
Solved
I have an model PointOfContact which has_many Systems. From the Systems side I want to identify the PointOfContact as either the technical_manager or project_manager (or both). While still only kee...
Hydrastis asked 14/3, 2011 at 4:34
2
Solved
I am using CakePHP 3.2. I have two tables service_requests and coupon_history
service_requests table
CREATE TABLE `service_requests` (
`id` char(36) NOT NULL,
`request_id` bigint(20) NOT NULL,
...
Limbert asked 1/7, 2016 at 7:25
2
Solved
I am porting a Rails app to Rails 4.2. This Rails app contains some rather complex manual SQL code in associations - partly due to DB optimizations (e.g. subselects instead of JOINs), partly due to...
Fillagree asked 18/1, 2015 at 12:40
3
Solved
Let's say that I want to search for Events in my app.
When I display the results, I want to display who created the event, for instance.
Is there any way to add .includes(:user) somewhere, to avoi...
Deanedeaner asked 26/11, 2011 at 23:11
2
Solved
I am using cakePHP version 3.x.
When i query the MessagesTable i want to get the Users data for the the sender and the receiver of the message. I have done this many times in cakePHP 2 but i cant ...
Diaconate asked 19/6, 2015 at 1:2
1
Solved
I started learning this stuff from the Flask Mega Tutorial. When he gets into Many-to-Many relationships, he creates an association table like this:
followers = db.Table('followers',
db.Column('f...
Minter asked 22/5, 2015 at 22:33
1
Solved
If I have a 'belongs_to' association in a model, I'd like to know the notional difference between validating an association:
class Topping < ActiveRecord::Base
belongs_to :pancake
validates ...
Volvulus asked 12/3, 2015 at 14:18
2
Solved
Rails 3 can't perform validation for persited object when use collection_singular_ids=ids method
Is there any way to avoid automatically saving object while assigning collection attributes(collection_singular_ids=ids method)?
for example, I have the following Test and Package model, Package h...
Strohl asked 28/10, 2014 at 15:18
4
Solved
I am reviewing my knowledge in object-oriented programming. Under the relationship between classes topic, I have encountered some relationships which are a bit ambiguous to me.
I know dependency "...
Kathleenkathlene asked 23/2, 2014 at 11:53
3
Solved
I have some trouble finding a solution for this..
Error: Call to a member function schema() on a non-object
File: /Cake/Model/Model.php
Line: 3627
In my Database there are the tables articles,ha...
Akee asked 11/9, 2014 at 22:13
0
Visual studio doesn't seem to recognize c++ STL classes properly when it comes to generating class diagrams.
There are two options when right-clicking class elements in the generated diagrams:
-...
Stylolite asked 28/12, 2013 at 0:56
1
Solved
I want to implement a user's friends system in my app so i found the rails space solution very nice, the idea there is to create two lines in the Friendships table : the first line for the sender i...
Froehlich asked 12/10, 2013 at 21:52
2
Solved
I'm attempting to create a system where my site's users can favorites pages. Those pages have two types, either clubs or sports. So, I have four models, associated as such:
User Model:
class User...
Concupiscence asked 21/5, 2013 at 19:11
2
Solved
My problem is I've run into limitations of accepts_nested_attributes_for, so I need to figure out how to replicate that functionality on my own in order to have more flexibility. (See below for exa...
Mascle asked 26/3, 2013 at 22:13
1
Solved
I am using rails_admin to manage data in a rails application.
I have this class:
class Activity < ActiveRecord::Base
attr_accessible :content, :title, :category_id
belongs_to :category, :inv...
Interferometer asked 1/3, 2013 at 15:58
5
Solved
The models are: stores and product, and they are associated by:
var $belongsTo = array(
'Store' => array(
'className' => 'Store',
'foreignKey' => 'store_id'
))
var $hasMany = array(
...
Greensward asked 17/11, 2011 at 20:39
1
I'm re-doing an app and migrating data from an old app. The some of the models names will be the same, though not all of them.
I'm writing a rake task to connect to the old database, read the reco...
Roofer asked 1/6, 2013 at 14:56
6
Solved
I'm testing out extjs 4 and I have stumbled upon something, I can't seem to figure out.
I have simple object association: Snapshot - hasMany -> Model
Now, I am trying to use XTemplate to show thi...
Ulphiah asked 24/6, 2011 at 12:39
1
Solved
I have user model and a car model
I want to have a model which will hold the settings for each car and each user
so I do
class CarSettings < ActiveRecord::Base
belongs_to :user
belongs_to ...
Perjured asked 6/3, 2013 at 18:2
3
Solved
I have two tables:
currencies and rates
currencies: id:int, code:string, name: string
rates: id:int, top_currency_id:int, bottom_currency_id:int, rate:float
And I have two active records for t...
Ailment asked 24/2, 2013 at 20:11
1 Next >
© 2022 - 2024 — McMap. All rights reserved.