similar to: Sorting on a model method?

Displaying 20 results from an estimated 50000 matches similar to: "Sorting on a model method?"

2007 Aug 10
1
How to spec a model method
Still new to Specs... How do I create a spec to test a model method? Specifically, here is my spec: #testing model describe User do it "should have many user roles" do User.reflect_on_association(:user_roles).should_not be_nil end it "should have many roles though user roles" do User.reflect_on_association(:roles).should_not be_nil end it "should know
2006 Aug 16
1
Naming rights_roles join model using has_many :through and polymorphic associations
Hi. I have a couple of best practices questions regarding polymorphic associations, naming join tables and user permissions. Currently I have implemented the user authentication model from the rails recipes book. Basically it goes something like this: MODEL CLASSES: class User < ActiveRecord::Base has_and_belongs_to_many :roles end class Role < ActiveRecord::Base
2006 Apr 12
0
Looking for a simpler model using :through associations
Hi. I''m building a setup where I have users and groups, and a user can have an optional title in a group (eg. "owner"). I''m doing this using "has_many :through" associations, using a Role model object as the join hub: class User < ActiveRecord::Base has_many :roles, :dependent => :destroy has_many :groups, :through => :roles end class
2005 Nov 09
0
Sorting has_many relationships
Hi Railers! I''m building a new website for our bar-foos-league (league for foosball players who play in bars in Zurich, Switzerland ;-) Being a bit of a noob when it comes to rails and web development in general, I''ve come across a few questions. One concerns sorting of a has_many relationship, for instance. I''ve got a League model, which has_many TeamConfigs
2011 Feb 08
0
Sorting by inner has_many through attribute
Hello everyone, For this model: class User < ActiveRecord::Base has_many :component_users, :dependent => :destroy has_many :components, :through => :component_users, :conditions => [''components.active = ?'',true] accepts_nested_attributes_for :component_users, :reject_if => lambda { |a| a[:components].blank? || a[:components] [:name].blank? },
2006 Aug 06
1
Sorting through relationships
Hi, I''m having a rather annoying problem which can only be explained with an example, so here we go. I have a Person class which has_many :assets. An Asset has_one :game. I would like every Person''s asset to be sorted by its game''s title, similar to this: has_many :assets, :order => ''game.title'' That doesn''t seem to work. A
2008 Jan 24
2
[LLVMdev] llvm-gcc + abi stuff
<moving this to llvmdev instead of commits> On Jan 22, 2008, at 11:23 PM, Duncan Sands wrote: >> Okay, well we already get many other x86-64 issues wrong already, but >> Evan is chipping away at it. How do you pass an array by value in C? >> Example please, > > I find the x86-64 ABI hard to interpret, but it seems to say that > aggregates are classified
2006 May 25
5
Model Structure Advise
Hi, I''m starting to build a simple (?!) FAQ system, and I''d like some advice on setting up the model relationships. I was going to go with a simple system of a Category table and a FAQ table (holding questions and answers) - where one FAQ belongs to one category. That''s all nice - a simple has_many / belongs_to relationship. Then I decided to add another level - Area.
2006 Jan 07
4
To Chris Hall - Re: DB Modelling the Rails way - Opinions??
Chris, Finally got time to fully play with your suggestions. Had to re-code a bit of stuff but the concept works - just like a bought one :~). Many thanks for the solution, Kind Regards, Eric. For those curious - here''s what it was about; On Monday 02 January 2006 02:10, Eric Sloane tried to type something like: > Hi, > I''m trying to figure the most efficient way to
2006 May 18
3
Model Madness: habtm vs through
This has me scratching my head: a Person has many Things a Person has many Collections a Collection has many Things ...Things in a Collection are ordered ...Things in a Collection can be related to (created by) any User ...a collection has additional attributes, such as a name etc I am confused about habtm in rails (especially when using acts_as_habtm_list) vs. going the :through route.
2008 Nov 10
2
Sort model based on max value of has_many field
Hi, I have models such as: class Team < ActiveRecord::Base has_many :games end class Game< ActiveRecord::Base belongs_to :team end So there are many (well, 0 to 6) games for each team. Team game has a "score". I would like to get a list of the teams, sorted by the highest scoring game - sort of a ranking based on highest score. I''ve tried several cominations of
2009 Jul 31
2
Undefined method updated? for <model object>
Hi, I have two model say- ZipCode < ActiveRecord::Base belongs_to :state_provinces end StateProvince < ActiveRecord::Base has_many :zip_codes end if I do @zip_code.update_atribute(:city, "My City") its giving Undefined method updated? for StateProvince if I remove belongs_to specifier in ZipCode class then it work fine. Any alternate solution?? Thanks -- Regards, Himanshu
2015 Aug 20
2
[RFC] Aggreate load/store, proposed plan
----- Original Message ----- > From: "deadal nix" <deadalnix at gmail.com> > To: "Hal Finkel" <hfinkel at anl.gov> > Cc: "Mehdi Amini" <mehdi.amini at apple.com>, "llvm-dev" <llvm-dev at lists.llvm.org> > Sent: Thursday, August 20, 2015 4:09:17 PM > Subject: Re: [llvm-dev] [RFC] Aggreate load/store, proposed plan >
2015 Aug 20
2
[RFC] Aggreate load/store, proposed plan
It is pretty clear people need this. Let's get this moving. I'll try to sum up the point that have been made and I'll try to address them carefully. 1/ There is no good solution for large aggregates. That is true. However, I don't think this is a reason to not address smaller aggregates, as they appear to be needed. Realistically, the proportion of aggregates that are very large
2006 Jul 01
6
Sorting by an attribute on a associated table
So, I have a User has_many :profiles. The most recently dated profile is considered the current one. I need to sort these users by name, but the name attribute is a member of the associated table. Is there any easy way to do this other than with some ugly find_by_sql? Maybe a more general question - is there a common solution to sorting in Ruby? -- Posted via http://www.ruby-forum.com/.
2015 Mar 06
2
[LLVMdev] Optimizing out redundant alloca involving byval params
Reid is right that this would go in memcpyopt, but... we there's an active discussion on the commit list which will solve this through a different mechanism. There's an active desire to avoid teaching GVN and related pieces (of which memcpyopt is one) about first class aggregates. We don't have enough active users of the feature to justify and maintain the complexity. If you
2017 Mar 08
3
Current preferred approach for handling 'byval' struct arguments
On 7 March 2017 at 17:58, Reid Kleckner <rnk at google.com> wrote: > Today, the vast majority of target in Clang coerce aggregates passed this > way into appropriate word-sized types. They all use their own custom > heuristics to compute the LLVM types used for the coercions. It's terrible, > but this is the current consensus. > > I would like to improve the situation
2015 Aug 21
3
[RFC] Aggreate load/store, proposed plan
----- Original Message ----- > From: "deadal nix" <deadalnix at gmail.com> > To: "Hal Finkel" <hfinkel at anl.gov> > Cc: "Mehdi Amini" <mehdi.amini at apple.com>, "llvm-dev" <llvm-dev at lists.llvm.org> > Sent: Friday, August 21, 2015 1:24:04 AM > Subject: Re: [llvm-dev] [RFC] Aggreate load/store, proposed plan >
2023 Oct 16
1
Create new data frame with conditional sums
If one makes the reasonable assumption that Pct is much larger than Cutoff, sorting Cutoff is the expensive part e.g O(nlog2(n) for Quicksort (n = length Cutoff). I believe looping is O(n^2). Jeff's approach using findInterval may be faster. Of course implementation details matter. -- Bert On Mon, Oct 16, 2023 at 4:41?AM Leonard Mada <leo.mada at syonic.eu> wrote: > > Dear
2006 Jan 02
5
DB Modelling the Rails way - Opinions??
Hi, I''m trying to figure the most efficient way to model the following. I can think of at least two ways to relate the tables but from a client/server perspective! I''m wondering how to best (and elegantly)relate them from an AR perspective. A project has many people, A person can work on many projects at any time, A project has many roles, A role is performed by a person, A