vendredi 20 mars 2015

Ruby on Rails Routing Confusion

I have a ruby on rails site with a page called "meetings". These meetings currently work fine, but I want to change the way that one of the drop downs displays its data. Currently, I have this in my controller/view:


Controller



@meeting_times = MeetingTime.select("id, meeting_type, meeting_at").where("
(meeting_at > ?)", Time.now + 1.week).order("meeting_at")


View



<%= f.select :meeting_time_id, options_from_collection_for_select
(@meeting_times, "id", "meeting_at") %>


Currently, as you can see, the dropdown just shows the meeting time. What I want to do make the dropdown show the meeting_type + meeting_time in one string. This sounds easy, however meeting_type is an int value. So, I would need to say "If meeting_type == 0 then display 'Staff Meeting' + meeting_time", and so on. How can I accomplish this without changing the database values for meeting_type?


Aucun commentaire:

Enregistrer un commentaire