Bryan Yes that makes sense, I was thinking while typing, but you managed to do the thinking before the typing ;-)
Is the id_is a hobo extension? I searched on the 'Miscellaneous Model Extension' and in regular Rails api, but didn't see anything like that. I have resorted to things like: Report.find_all_by_bird_id_and_location_id(bird.id,self.id) Ankur On Mar 28, 3:00 pm, Bryan Larsen <[email protected]> wrote: > AFAICT, this is what you're looking for. > > class Location > ... > has_many :birds, :through => :reports > has_many :reports > > def ra_index(bird) > reports.bird_id_is(bird.id).size / reports.size > end > end > > One note: you probably want to use all-lowercase names for your > field/column names. In Ruby, names that start with uppercase are used > for constants. > > Bryan > > On 11-03-27 10:23 AM, Kaustubh Naik wrote: > > > > > > > > > > > On Sat, Mar 26, 2011 at 4:26 AM, Matt Jones <[email protected] > > <mailto:[email protected]>> wrote: > > > I'm not quite sure what you mean - row and record counts of what? > > It'll be a lot easier to help if we have a clearer idea of what your > > models are and how they're related. > > > Extremely sorry for the inadequate information provided. Here is what I > > want to do > > I have three models namely Bird, Location and Report! > > > The report is model looks like this > > > class Report < ActiveRecord::Base > > > hobo_model # Don't put anything above this > > > fields do > > Date :date > > #Plumage :string > > Plumage enum_string(:Breeding, :NonBreeding ) > > #Weather :string > > Weather enum_string(:Cloudy, :Sunny, :Humid) > > RAIndex :integer > > Time enum_string(:Dawn, :Morning, :Noon, :Evening, :Dusk, :Night) > > timestamps > > end > > belongs_to :bird > > belongs_to :location > > > The field RA Index is a value assigned with each bird specie. It is the > > ratio of number of reports in which 'X' bird is reported at 'P' location > > to the number total reports for that location. I need to calculate that > > Index. > > Please guide me through. > > > -- > > You received this message because you are subscribed to the Google > > Groups "Hobo Users" group. > > To post to this group, send email to [email protected] > > <mailto:[email protected]>. > > To unsubscribe from this group, send email to > > [email protected] > > <mailto:hobousers%[email protected]>. > > For more options, visit this group at > > http://groups.google.com/group/hobousers?hl=en. > > > -- > > Kaustubh Naik > > Goa-India > > >http://geekblues.in/ > > [email protected] <mailto:[email protected]> > > > -- > > You received this message because you are subscribed to the Google > > Groups "Hobo Users" 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/hobousers?hl=en. -- You received this message because you are subscribed to the Google Groups "Hobo Users" 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/hobousers?hl=en.
