On 16 August 2011 09:58, merbivore <eshward...@gmail.com> wrote: Please don't top post, it makes it difficult to follow the thread. Insert your reply at appropriate point in previous message. Thanks.
> Hi Colin, > > Thanks for the quick reply. I can't sort out the database design > becoz am pulling the data from SCOM sql server. > Could you help me how can i solve this one please. What about my other suggestion to catch the error? Colin > > On Aug 16, 1:55 pm, Colin Law <clan...@googlemail.com> wrote: >> On 16 August 2011 09:49, merbivore <eshward...@gmail.com> wrote: >> >> >> >> > Hi Everyone, >> >> > I am trying to solve this problem, but couldn't able to get the >> > solution. I hope i will get some help here. >> >> > I am using these three find methods to get different types of >> > devices. I dont have any relationships between any models. >> >> > windows_devices = BaseManagedEntity.find(:all, >> > :select => "b.BaseManagedEntityInternalId, c.NetworkName, >> > c.IPAddress, s.HealthState, s.LastModified", >> > :joins => "as b INNER JOIN mt_computer as c ON >> > c.basemanagedentityid = b.basemanagedentityid >> > INNER JOIN state as s ON b.basemanagedentityid = >> > s.basemanagedentityid", >> > :conditions => "IsManaged = 1 and s.LastModified = (select >> > MAX(LastModified) from state where basemanagedentityid = >> > s.basemanagedentityid)", >> > :order => "s.LastModified DESC", >> > :group => "b.BaseManagedEntityInternalId, s.HealthState, >> > s.LastModified, c.NetworkName, c.IPAddress" ) >> >> > unix_devices = BaseManagedEntity.find(:all, >> > :select => "b.BaseManagedEntityInternalId, >> > c.NetworkName_360E5A02_BC9E_0000_2614_1972E304088A, >> > c.IPAddress_360E5A02_BC9E_0000_2614_1972E304088A, s.HealthState, >> > s.LastModified", >> > :joins => "as b INNER JOIN MTV_Computer_0 as c ON >> > c.basemanagedentityid = b.basemanagedentityid >> > INNER JOIN state as s ON b.basemanagedentityid = >> > s.basemanagedentityid", >> > :conditions => "IsManaged = 1 and s.LastModified = (select >> > MAX(LastModified) from state where basemanagedentityid = >> > s.basemanagedentityid)", >> > :order => "s.LastModified DESC", >> > :group => "b.BaseManagedEntityInternalId, s.HealthState, >> > s.LastModified, c.NetworkName_360E5A02_BC9E_0000_2614_1972E304088A, >> > c.IPAddress_360E5A02_BC9E_0000_2614_1972E304088A" ) >> >> > network_devices = BaseManagedEntity.find(:all, >> > :select => "b.BaseManagedEntityInternalId, >> > c.Name_65AC01F1_F20E_CE0D_42CA_B24D1DE49E5F, >> > c.IPAddress_65AC01F1_F20E_CE0D_42CA_B24D1DE49E5F, s.HealthState, >> > s.LastModified", >> > :joins => "as b INNER JOIN mt_networkdevice as c ON >> > c.basemanagedentityid = b.basemanagedentityid >> > INNER JOIN state as s ON b.basemanagedentityid = >> > s.basemanagedentityid", >> > :conditions => "IsManaged = 1 and s.LastModified = (select >> > MAX(LastModified) from state where basemanagedentityid = >> > s.basemanagedentityid)", >> > :order => "s.LastModified DESC", >> > :group => "b.BaseManagedEntityInternalId, s.HealthState, >> > s.LastModified, c.Name_65AC01F1_F20E_CE0D_42CA_B24D1DE49E5F, >> > c.IPAddress_65AC01F1_F20E_CE0D_42CA_B24D1DE49E5F" ) >> >> > After finding these am concatenating all these three like this >> >> > devices = windows_devices.concat(unix_devices) >> > @devices = devices.concat(network_devices) >> >> > I need to loop @devices in the view and i need to display the IP >> > Address for the all the devices. >> >> > When i do <%= device.IPAddress %> am getting error because the other >> > device uses the attribute >> > IPAddress_65AC01F1_F20E_CE0D_42CA_B24D1DE49E5F . >> >> > I was struck with this issue. Please help me in this issue asap. >> >> Catch the error and take appropriate action? Even better sort out the >> database design. >> >> Colin > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.