Попробуйте что-нибудь такое.
class News < ActiveRecord::Base
belongs_to :user, foreign_key: :login, primary_key: :login
end
class User < ActiveRecord::Base
has_many :news, foreign_key: :login, primary_key: :login
end
Миграции
class CreateNews < ActiveRecord::Migration
def up
create_table :news do |t|
t.string :login, limit: 50
t.timestamps null: false
end
add_foreign_key :news, :users, column: :login
end
def down
remove_foreign_key :news, name: :login
drop_table :news
end
end
class CreateUsers < ActiveRecord::Migration
def change
create_table :users, id: false, primary_key: :login do |t|
t.string :login, limit: 50, null: false
t.timestamps null: false
end
end
end