#more elegante way? 
sector = Sector.create(:name => name) unless sector = Sector.find_by_name(sector)

Ruby more elegant way

by RoadHouse, December 01, 2011 09:52, 5 refactorings, tagged with ruby, activerecord, rails3

no ideas about it, rails 3....

70089e712ed13abb99bec89bd5bfba77 Talk
@topic = if (defined? @parent.topic) then
                 @parent.topic
               else
...

Ruby Ugly ruby if statement.

by acreek.myopenid.com, November 29, 2011 11:51, 5 refactorings, tagged with ruby1.9, rails3

I know there has to be a be...

55502f40dc8b7c769880b10874abc9d0 Talk
def set_name
    deal_date = self.deal_date
    if (4..12).to_a.include?(self.deal_date.month)
...

Ruby Refactor this code

by https://www.google.com/accounts/o8/id?id=AItOawl-DJ5xgYVFKrrLOGZqwCiGLkx38LeB1cU, November 10, 2011 21:43, No refactoring, tagged with ruby, rails3

Please refactor this code.....

55502f40dc8b7c769880b10874abc9d0 Talk
match '/:id', to: 'high_voltage/pages#show', 
as: :static, 
via: :get, 
...

Ruby Rails route

by kain, August 17, 2011 21:56, No refactoring, tagged with rails, rails3

High Voltage match :id base...

25e782eb7e799e78d781b0026fc6a4d8 Talk
module ApplicationHelper

  def render_tree(nodes)
...

Ruby A tree helper for Rails

by pixoo.myopenid.com, July 19, 2011 15:24, No refactoring, tagged with rails3

I try to create a helper ab...

Bf7c47d039188492e68961ce783285ad Talk
# An example email body that someone can type. Items within the ~ are variables
Dear ~FIRST_NAME~ ~LAST_NAME~

...

Ruby Can I compact multiple gsub...

by https://www.google.com/accounts/o8/id?id=AItOawm08TIbvnrtw3uiIaBHRyP0cUWTGDvieLk, June 22, 2011 06:45, 3 refactorings, tagged with rails3

Hey All, I have several gsu...

55502f40dc8b7c769880b10874abc9d0 Talk
def self.categories_with_count
    Category.find_by_sql("SELECT categories.name AS name, categories.slug AS slug, COUNT(categorizations.id) AS count FROM categories LEFT OUTER JOIN categorizations ON categories.id = categorizations.category_id GROUP BY categorizations.category_id, categories.name, categories.slug ORDER BY categories.name")
end

Ruby Refactoring SQL Query in Ru...

by Elhu, May 24, 2011 14:14, 5 refactorings, tagged with rails activerecord, rails3

Hi!

I'm trying to retrie...

55bb5ae89ab81b436969697f65b60533 Talk
def create
    @lead = Lead.new(params[:lead])
    @contact = @lead.contact_detail = ContactDetail.new(params[:contact_detail])
...

Ruby Best way to do this

by https://www.google.com/accounts/o8/id?id=AItOawl-DJ5xgYVFKrrLOGZqwCiGLkx38LeB1cU, April 28, 2011 00:08, 6 refactorings, tagged with controller, rails3

Thanks

55502f40dc8b7c769880b10874abc9d0 Talk
def my_method
    if session[:my_params].try(:include?, :answer)
      session[:my_params][:answer]
...

Ruby Best way to refactor this p...

by https://me.yahoo.com/a/yQQFEJFypZkPnGHhWDE9yJgIJFgRKgwrkB8WqSHv, April 27, 2011 09:06, 10 refactorings, tagged with rails, rails3

Hi,

I am quite new to Ra...

55502f40dc8b7c769880b10874abc9d0 Talk
#1
@message= @bunker.messages.create(params[:message])

...

Ruby ---message: is appearing in...

by https://www.google.com/accounts/o8/id?id=AItOawkLfuak4NfSyVOPz3IfXeLJucIRBxwgBgA, April 03, 2011 21:21, 2 refactorings, tagged with ruby, database, rails3, message

I'm simply trying to insert...

55502f40dc8b7c769880b10874abc9d0 Talk
def self.find_for(options = {})
    scope = scoped
    scope = scope.where(:hook => options[:hook].to_s)  if options[:hook]
...

Ruby ActiveRecord query construc...

by https://www.google.com/accounts/o8/id?id=AItOawmLF7gR3CIpZoZXbwO7fiD2QWYltD3lwpM, December 23, 2010 15:27, 1 refactoring, tagged with rails, sql, activerecord, rails3, arel

Rails 3.0.3

This method ...

55502f40dc8b7c769880b10874abc9d0 Talk
class Topic < ActiveRecord::Base

  # Finds most active users in the topic
...

Ruby most active users through r...

by edgarjs, November 05, 2010 20:03, 1 refactoring, tagged with associations, rails3, arel, finders

There are topics, each topi...

380f2ee82510287050b118947e8526dd Talk