[Rails] Re: Best practice question...

2009-07-27 Thread Rob Biedenharn
On Jul 27, 2009, at 3:21 PM, Ashley wrote: > Hi Guys! > > Thanks for both of your input. > > I've opted for a helper method that looks something like: > > module UsersHelper > > def has_relationship_with?( other_user ) >var_name = "@has_relationship_with_#{other_user.id}" >instance_variab

[Rails] Re: Best practice question...

2009-07-27 Thread Ashley
Hi Guys! Thanks for both of your input. I've opted for a helper method that looks something like: module UsersHelper def has_relationship_with?( other_user ) var_name = "@has_relationship_with_#{other_user.id}" instance_variable_get(var_name) || instance_variable_set(var_name, curren

[Rails] Re: Best practice question...

2009-07-27 Thread James Englert
You might want to memoize the results of that function to prevent unnecessary hits to the database during the same request. On Mon, Jul 27, 2009 at 2:21 PM, Rob Biedenharn wrote: > > On Jul 27, 2009, at 12:26 PM, Ashley wrote: > > Hello guys! > > > > Question: > > > > Views should be "dumb" and m

[Rails] Re: Best practice question...

2009-07-27 Thread Rob Biedenharn
On Jul 27, 2009, at 12:26 PM, Ashley wrote: > Hello guys! > > Question: > > Views should be "dumb" and models should deal with db queries... > > but what if you have a situation like so > > class User < ActiveRecord::Base > > def has_relationship_with?( other_user ) >!relationships.find_by_ot