Hi Colin,
I tried like this also <%= check_scom_column(device) %> in the view.
And in helper i provided like this
def check_scom_column(device)
if device.IPAddress
return device.IPAddress
elsif device.IPAddress_65AC01F1_F20E_CE0D_42CA_B24D1DE49E5F
return device.IPAddress_65AC01F1_F20E_CE0D_42CA_B24D1DE49E5F
end
end
But it is giving me error undefined method `IPAddress' for
#<BaseManagedEntity:0x492d7d0>
Please help me Colin. I was struck with this issue from 2 days.
On Aug 16, 1:58 pm, merbivore <[email protected]> wrote:
> 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.
>
> On Aug 16, 1:55 pm, Colin Law <[email protected]> wrote:
>
> > On 16 August 2011 09:49, merbivore <[email protected]> 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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.