I'm new to ruby on rails.I faced to a situation which i need to get the latest created object from database table.
Currently if there are 2 records for same id it gives me both objects.Finally i get a reports of all.Then the date was printed on two columns.How to get the last created to my report?
if ticket.user_ticket_actions.present?
ticket.user_ticket_actions.each do |user_ticket_action|
if user_ticket_action.act_quality_control.try(:approved) == false
ticket_content << user_ticket_action.act_quality_control.created_at.to_datetime.strftime("#{INOCRM_CONFIG['short_date_format']} #{INOCRM_CONFIG['time_format']}")
end
end
end
According to code if there are two act_quality_control days, i need to get the latest one only