-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Association not working #149
Comments
Have you tested this with possibly: class ActionHistory < ApplicationRecord
extend ActiveHash::Associations::ActiveRecordExtensions
belongs_to_active_hash :action_type
end Some people have all active record objects extending |
@kbrock What would I have in the |
It sounded like you already tried this class ActionHistory < ApplicationRecord
extend ActiveHash::Associations::ActiveRecordExtensions
belongs_to_active_hash :action_type
end
class ActionType < ActiveHash::Base
include ActiveHash::Associations # this looks like the one
has_many :action_histories
self.data = [
{:id => 1, :name => 'call_started', :friendly_name => 'Call Started'},
{:id => 2, :name => 'call_ended', :friendly_name => 'Call Ended'},
{:id => 3, :name => 'email_sent', :friendly_name => 'Email Sent'},
{:id => 4, :name => 'email_received', :friendly_name => 'Email Received'},
{:id => 5, :name => 'note', :friendly_name => 'Note'}
]
end Did you try something like this? |
I have the following two models:
And my
action_histories
table hasaction_type_id
column for the relationship.However when I try and access
ActionHistory.all.first.action_type.name
I get the error thataction_type
is not defined.I've tried using
extend ActiveHash::Associations::ActiveRecordExtensions
andinclude ActiveHash::Associations
but that doesn't get it working either...I'm using latest version of Gem and Rails 5.0.1
The text was updated successfully, but these errors were encountered: