vendredi 26 mai 2017

Rails detect if object is session table

I use rails 3.2. I try to add a global check on a field of my model called account_id. My problem is that there are tables that not have this field like sessions table and others. So I have my object self and I use if condition like

if self.name.to_s!="Base" and self.name!="Session"

but the session object passed the if condition, below the error

PG::UndefinedColumn: ERROR: column sessions.account_id does not exist

How I can detect if self is session object? I see that in other case self in my function is for example NamTable+attributes ex Base[id:ecc]

Aucun commentaire:

Enregistrer un commentaire