ExtJS 4: Models with Associations and Stores

Konrad. I recently faced with dealing with Models+Associations+Stores. This wasn’t very pleasent experience. Here is what I’ve learned: Let’s say we have Store1, Store2, Model1, Model2, Grid1, Grid2. Grid1 uses Store1, Store1 uses Model1 and similarly Grid2 uses Store2, Store2 uses Model2. So far all is working, data is loading and so on. But now … Read more

Flask/SQLAlchemy – Difference between association model and association table for many-to-many relationship?

My apologies, I finally stumbled across the answer in the SQLAlchemy docs… https://docs.sqlalchemy.org/en/latest/orm/basic_relationships.html#many-to-many …where they explicitly define the difference: Many to Many adds an association table between two classes. association_table = Table(‘association’, Base.metadata, Column(‘left_id’, Integer, ForeignKey(‘left.id’)), Column(‘right_id’, Integer, ForeignKey(‘right.id’)) ) The association object pattern is a variant on many-to-many: it’s used when your association table … Read more

Same Model for Two belongs_to Associations

Thanks to jamesw over at RailsForum.com: Same Model for Two belongs_to Associations a solution has been found. class System < ActiveRecord::Base belongs_to :project_manager, :class_name => ‘PointOfContact’, :foreign_key => ‘project_manager_id’ belongs_to :technical_manager, :class_name => ‘PointOfContact’, :foreign_key => ‘technical_manager_id’ end class PointOfContact < ActiveRecord::Base has_many :project_managed_systems, :class_name => ‘System’, :foreign_key => ‘project_manager_id’ has_many :technical_managed_systems, :class_name => ‘System’, … Read more

Aggregation vs Composition vs Association vs Direct Association

Please note that there are different interpretations of the “association” definitions. My views below are heavily based on what you would read in Oracle Certification books and study guides. Temporary association A usage inside a method, its signature or as a return value. It’s not really a reference to a specific object. Example: I park … Read more

Rails association with multiple foreign keys

TL;DR class User < ActiveRecord::Base def tasks Task.where(“owner_id = ? OR assigneed_id = ?”, self.id, self.id) end end Remove has_many :tasks in User class. Using has_many :tasks doesn’t make sense at all as we do not have any column named user_id in table tasks. What I did to solve the issue in my case is: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)