Skip to content

user.bookmarks, user.likes and user.dislikes fail unless my recommendable class has an 'id' key #70

@mathieugagne

Description

@mathieugagne

id is hard coded as the primary key. Nothing wrong normally but I have this legacy database ported to Rails that doesn't respond to @instance.id.

It fails in many levels but the first would be here:
https://github.com/davidcelis/recommendable/blob/master/lib/recommendable/rater/bookmarker.rb#L74

If my primary key is a string like 'AAPL' then calling to_i on it returns 0. Hence requesting all bookmarks for a specific user will trigger:

Company.where(id: 0)

Where there are no columns id for companies AND there wouldn't be an id for 0.
Would be great if either we could pass as an option to recommends or if it could look at ActiveRecord relationships:
has_many :companies, primary_key: :ticker

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions