Rails Model has_many with multiple foreign_keys

Found a simple answer on IRC that seems to work (thanks to Radar): class Person < ActiveRecord::Base belongs_to :father, :class_name => ‘Person’ belongs_to :mother, :class_name => ‘Person’ has_many :children_of_father, :class_name => ‘Person’, :foreign_key => ‘father_id’ has_many :children_of_mother, :class_name => ‘Person’, :foreign_key => ‘mother_id’ def children children_of_mother + children_of_father end end

Generating Swift models from Core Data entities

Lets have a look on the Objective-C way: Person.h (Header-File) #import <Foundation/Foundation.h> #import <CoreData/CoreData.h> @interface Person : NSManagedObject @property (nonatomic, retain) NSString *name; @end Person.m (Implementation-File) #import “Person.h” @implementation Person @dynamic name; @end Swift The documentation already included in Xcode6-Beta says: Core Data provides the underlying storage and implementation of properties in subclasses of the … Read more

How to translate model in Ruby class/module namespace?

I have checked ‘model_name.human’ source code and found ‘i18n_key’ method. I have tried this: irb(main):006:0> Products::Car.model_name.i18n_key => :”products/car” Then I changed my yml file to this: activerecord: models: products/car: “Автомобиль” attributes: products/car: owner: “Владелец” and it works! EDIT: For further reference: the i18n_key is set in the initializer of ActiveModel::Name https://github.com/rails/rails/blob/375a4143cf5caeb6159b338be824903edfd62836/activemodel/lib/active_model/naming.rb#L147 and it is simply … Read more

PHPStorm is not recognizing methods of my Model class in Laravel 5.0 [duplicate]

If you want a class extending Model to recognize Eloquent methods, just add the following in the top PHPDoc comment on the class: @mixin Eloquent Example: <?php namespace App; use Carbon\Carbon; use Eloquent; use Illuminate\Database\Eloquent\Model; /** * Post * * @mixin Eloquent */ class Post extends Model { Edit Laravel 6+ (Last tested on 9.41.0) … Read more