#more elegante way? sector = Sector.create(:name => name) unless sector = Sector.find_by_name(sector)
Ruby more elegant way
@topic = if (defined? @parent.topic) then
@parent.topic
else
...
Ruby Ugly ruby if statement.
I know there has to be a be...
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.....
match '/:id', to: 'high_voltage/pages#show', as: :static, via: :get, ...
Ruby Rails route
High Voltage match :id base...
module ApplicationHelper def render_tree(nodes) ...
Ruby A tree helper for Rails
I try to create a helper ab...
# 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...
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...
Hi!
I'm trying to retrie...
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
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...
#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...
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 ...
class Topic < ActiveRecord::Base # Finds most active users in the topic ...
Ruby most active users through r...
There are topics, each topi...
no ideas about it, rails 3....