charlotte-ruby / impressionist

Rails Plugin that tracks impressions and page views
MIT License
1.53k stars 311 forks source link

Add associations to models/impression.rb #266

Open sithara opened 6 years ago

sithara commented 6 years ago

Hi Can we add impression.rb to app/models that takes in user_id from a table other than users table? I tried adding belongs_to association but it does not work.

class SomeUser < ActiveRecord::Base validate :user_name end

Is there some way I can access this as Impression.first.user_name => which gives me the current user name for that particular impression

Kind Regards Sithara

codeundercoverdev commented 3 years ago

I am also trying to do this. I tried to make a model like normal but it gets ignored by rails.

class Impression < ApplicationRecord
    belongs_to :sticker, optional: true
end