Skip to main content
11 events
when toggle format what by license comment
Jun 26, 2017 at 18:36 history migrated from stackoverflow.com (revisions)
Jun 13, 2017 at 13:30 comment added Pavan @SergioTulentsev Yeah! Since you already pointed out in your answer, I have to think of another way and the final result is this answer :)
Jun 13, 2017 at 13:28 comment added Sergio Tulentsev @Pavan: for simple, check my answer :)
Jun 13, 2017 at 13:26 comment added Pavan @SergioTulentsev Yeah right! I can't think of a way to make it simple. Also since the divice name and vendor name should be shown in two seperate <td></td>, I finally end up with get_device_name_and_vendor_name(device_vendor)[0] and get_device_name_and_vendor_name(device_vendor)[1]
Jun 13, 2017 at 13:19 comment added Sergio Tulentsev @Pavan: 2 queries per call. And you make two calls.
Jun 13, 2017 at 13:16 comment added Pavan @SergioTulentsev I'm not sure how many queries it will make. I'm guessing 2. Correct me if I'm wrong.
Jun 13, 2017 at 13:11 comment added Sergio Tulentsev @Pavan: you realize your proposed code makes 4 queries?
Jun 13, 2017 at 13:04 comment added Sergio Tulentsev @devel: foreign key column does not have to be device_id. You can customize it. Something along the lines of belongs_to :device, foreign_key: :abbr. Consult docs for the exact syntax.
Jun 13, 2017 at 12:58 comment added Pavan @devel Associations in your case is a long shot,since you need to add corresponding Foreign Key in the tables and the data in the db need to be altered too to map the corresponding records. But they provide more flexibility. My suggestion, take it or leave it :)
Jun 13, 2017 at 12:49 comment added Rajkaran Mishra Can you also explain how association can be applied in this scenario as device_id is not getting used so that I can seed all the data to avoid association
Jun 13, 2017 at 12:42 history answered Pavan CC BY-SA 3.0