In ruby if you have a hash, for e.g. :
  hash = {}
  then you can say this: hash.merge!("name" => "something")
  this will append that label inside the hash.


On Fri, Aug 19, 2011 at 2:00 PM, merbivore <[email protected]> wrote:

> Hi Everyone,
>
>   I have small doubt in rails. I hope i will get solution from here.
>
>
> I am using rails find query like this
>
>
>  def self.data_query(params,label)
>     BaseManagedEntity.find(:all,
>       :select => "b.BaseManagedEntityInternalId,
> c.#{DEVICE_NAMES[label]}, c.#{DEVICE_IPS[label]}, s.HealthState,
> s.LastModified",
>       :joins =>  "as b INNER JOIN #{TABLE_NAMES[label]} as c ON
> c.basemanagedentityid = b.basemanagedentityid
>                   INNER JOIN state as s ON b.basemanagedentityid =
> s.basemanagedentityid",
>       :conditions => BaseManagedEntity.all_conditions(params,
> label),
>       :order => "s.LastModified DESC",
>       :group => "b.BaseManagedEntityInternalId, s.HealthState,
> s.LastModified, c.#{DEVICE_NAMES[label]}, c.#{DEVICE_IPS[label]}" )
>  end
>
>
>  DEVICE_NAMES = {"windows" => "NetworkName", "unix" =>
> "NetworkName_360E5A02_BC9E_0000_2614_1972E304088A",
>                  "network" =>
> "Name_65AC01F1_F20E_CE0D_42CA_B24D1DE49E5F"}
>
>  DEVICE_IPS   = {"windows" => "IPAddress", "unix" =>
> "IPAddress_360E5A02_BC9E_0000_2614_1972E304088A",
>                  "network" =>
> "IPAddress_65AC01F1_F20E_CE0D_42CA_B24D1DE49E5F"}
>
>  TABLE_NAMES   = {"windows" => "mt_computer", "unix" =>
> "MTV_Computer_0",
>                   "network" => "mt_networkdevice"}
>
>  HEALTH_STATES = {"Normal" => 1, "Warning" => 2, "Critical" => 3,
> "Healthy" => 1 }
>
>
> The abvoe method will call from this method
>
>  def self.all_devices(params)
>    all_devices = data_query(params, "windows") + data_query(params,
> "unix") + data_query(params, "network")
>    all_devices.paginate((params[:page] || 1), CONSTANTS['PAGINATE']
> ['TEN'] )
>  end
>
>
> I want to merge a attribute called "device_type"( which i will define
> as attr_accessor)
> after find query based on the label i used so that i can use attribute
> in the views.
>
> How can i do that. Please help me in this issue.
>
> --
> 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.
>
>


-- 

Please consider the environment before printing this email.

Regards,
Surya

-- 
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.

Reply via email to