Accessing model info

Hi there,

I have a model called Subscription which contains (and therefore links)
a user_id and an event_id (both User and Event being additional models

When I call Subscription.find(user_id = 1) for example, it will return a
hash of all the records therein where user_id is equal to 1.

How, then, do I access the full details of an event from the event ID’s

I hope this makes sense to someone, any help is appreciated!




data = Subscription.find(user_id = 1)
p data.attributes # I think this will display every attribute
connected to that object.

puts “Subscribers lastname: #{data.lastname}”

Not even 50% sure it´ll work, but give it a try! :slight_smile:

Martin S.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs