Possible Duplicate:
Rails primary key and object id
I have the following code in my Event model
def event_tokens=(ids)
events = ids.split(',')
allowed_events = []
events.each do |i|
i = i.strip
event = Event.where("upper(name) = ?", i.upcase);
if event.present?
allowed_events << event.id #line w/ error
else
print "this doesnt exist, add in staging table " + i.to_s
end
end
self.event_ids = allowed_events
end
the event.id in the above code is throwing a warning
warning: Object#id will be
deprecated; use Object#object_id
when I changed event.id to event[:id] I’m getting an error
Symbol as array index
… returns a collection (well, technically, a proxy to a collection), not an ActiveRecord object.
Try: