James Bond wrote:

> #order can be "date" or "score" or "user"

Don't use @ unless you are really passing a variable to other methods in this 
class.

> @order = "date" #default
> @order = session[:order] if session[:order]
> @order = params[:order] if params[:order]

order = session[:order] || params[:order] || 'date'

Note I use single 'ticks' because I don't need the special abilities of "". 
That 
represents a very important style rule - use the simplest code you can. Think 
of 
"" as "costing more" than ''.

> orderby = "updated_on DESC" #default
> orderby = "score DESC" if @order == "score"
> orderby = "user" if @order == "user"

orderby = order == 'date' ? 'updated_on' : order

> session[:order] = @order
> 
> @results = Stats.find(:all, :order => orderby, :conditions..........


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