Forum: Ruby on Rails Accessing model info

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
13e43a569b89bb1bfb39df4fcfcdde1f?d=identicon&s=25 Mick (Guest)
on 2007-03-14 21:24
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!


3b1daae9f655c5dba51ff1cdf03f1bef?d=identicon&s=25 Martin Stabenfeldt (Guest)
on 2007-03-14 21:50
(Received via mailing list)

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! :)

Martin Stabenfeldt
This topic is locked and can not be replied to.