class Company
  has_many :stores
end
...

Ruby Active Record getting uniqu...

by kibyegn.myopenid.com, February 03, 2012 01:40, 1 refactoring, tagged with rails, short clean ruby, active record

I still think I could make ...

6d071ab3b1a56ebe43df404356331163 Talk
>> %w(Pending Processing Executed Canceled).each_with_index.map {|v, i| i}
=> [0, 1, 2, 3]

Ruby Get array of indexes from g...

by jibiel, December 08, 2011 00:18, 5 refactorings, tagged with rails, dry, ruby-1.9.2

Using it :in validates_incl...

4b3896c9b63e756621efa3746c32e91b Talk
<%= link_to (image_tag("sign_up_button.png", :alt => "Sign up now!"), "sign_up_now!") %>

Ruby Center Image link

by https://www.google.com/accounts/o8/id?id=AItOawktXnAcZIDUDRr6WbNX-CLR0FeppJSag2k, October 23, 2011 12:08, 1 refactoring, tagged with rails, image-link

I need placed image-link on...

55502f40dc8b7c769880b10874abc9d0 Talk
# chip away at the bonuses play through amounts
    bet_through_credit_remaining = self.wager
    self.user.bonuses.ranked.each do |bonus|
...

Ruby apply a credit over an orde...

by philrosenstein.myopenid.com, October 21, 2011 15:14, 15 refactorings, tagged with rails, activerecord, array, 2.3.x

example: if the credit is ...

20bffe332e5534f3ea328698ecb0a938 Talk
def steps
    unless @steps
      if scenario.class == Cucumber::Ast::OutlineTable::ExampleRow
...

Ruby unless.. if..

by https://www.google.com/accounts/o8/id?id=AItOawmZADKQPpupLegafoFEaOnWDyZ6Kd_VfMI, September 26, 2011 05:39, 3 refactorings, tagged with rails

These two methods both seem...

55502f40dc8b7c769880b10874abc9d0 Talk
class Job
  has_many :tasks

...

Ruby Convert SQL scopes to somet...

by KieranP, September 07, 2011 15:46, No refactoring, tagged with rails, postgres, named_scope, scopes

Using Rails 3.0.10, and Pos...

74198b06bc9e68739debfe6c23e070d3 Talk
.---. 
     |   v*
 .--------------.  
...

Ruby Instance-level authorization

by dagobah.myopenid.com, September 07, 2011 04:49, No refactoring, tagged with rails, database, authorization, instance-level

Is this database structur...

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
if @image.update_attributes params[:product_image]
  if request.xhr?
    render :json => { :status => 'success', :data => {:message => I18n.t('product_image.results.reordered')} }
...

Ruby DRY up a controller action

by Nick, August 05, 2011 11:13, 6 refactorings, tagged with rails, ruby, controller, DRY

Any suggestions for DRYing ...

49de4cd2f26705785cbef2b15a9df7aa Talk
has_many :contactships
      has_many :uers, :through => :contactships
...

Ruby CanCan through a join model

by https://www.google.com/accounts/o8/id?id=AItOawm0WvwBBHqoyBdwxEWpjuK_M183D0UXVII, July 12, 2011 21:09, 1 refactoring, tagged with rails, authorization, cancan, ability

Is there a better way to lo...

55502f40dc8b7c769880b10874abc9d0 Talk
def rating_stars(rating)
  output = []
  rating.round.times { output << content_tag(:span, "★", class: 'full') }
...

Ruby Generate span elements for ...

by verminvermin.myopenid.com, July 06, 2011 03:14, 3 refactorings, tagged with rails, helper method, ruby on rails

Is there a better/alternati...

55502f40dc8b7c769880b10874abc9d0 Talk
class IsbnsController < ApplicationController
  before_filter :correct_user, :only => [:destroy, :edit, :show, :update, :index, :new, :create]
  before_filter :correct_user_admin,   :only => [:destroy]
...

Ruby Horrific if/else nonsense i...

by https://www.google.com/accounts/o8/id?id=AItOawmBoZDYdn9kg9NpUnuCgDniTetBixwn3iQ, June 10, 2011 05:16, 2 refactorings, tagged with rails, ruby, if-else

Posting for the comedy/shoc...

55502f40dc8b7c769880b10874abc9d0 Talk
require 'active_support/core_ext'

class Float
...

Ruby Humanizing currency

by Stephen, May 03, 2011 10:44, No refactoring, tagged with rails, strings, money

Looking for a more succinct...

057e54d9a7b6ce3614413fcab825fca8 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
def shadow
    content_tag :div, :class => 'b-shadow' do
      result = ''
...

Ruby content_tag

by https://www.google.com/accounts/o8/id?id=AItOawnnR1uGNbbUG-ny6nYzDXxbIckLhtbxifo, April 05, 2011 08:21, 3 refactorings, tagged with rails, helpers

There is any special helper...

55502f40dc8b7c769880b10874abc9d0 Talk
composed_of :assistant_fee,
    :class_name => "Money",
    :mapping => [%w(assistant_fee_in_cents cents), %w(currency currency_as_string)],
...

Ruby Refactoring multiple compos...

by https://www.google.com/accounts/o8/id?id=AItOawlg3KkPp_EslfoIAWbF6uZYScrro2jwb-E, April 03, 2011 01:11, 1 refactoring, tagged with rails, ruby, activerecord

I have a model that has sev...

55502f40dc8b7c769880b10874abc9d0 Talk
<%= select_tag :editor_id, options_for_select(Member.where(:role => :editor).select {|m| m.authentications.count > 0 }.collect { |u| [u.name, u.id]  } ) %

Ruby messy Rails select

by bruno antunes, March 24, 2011 14:54, 2 refactorings, tagged with rails, ruby, activerecord

any help appreciated!

1b491994d6011d720e332af6e1ffd03b Talk
<% if @job.new_record? %>
  <%= f.radio_button :environment_id, env.id, :checked => env.is_default %>
<% else %>
...

Ruby radio select tag by default...

by corroded, March 23, 2011 10:12, 1 refactoring, tagged with rails

Is there a better way of do...

A53cdbd5cbc6e9fc944d35331a32e63c Talk
def search
    @search = params[:company_search]
    @results = Company.search @search, :include => :staff_id,
...

Ruby Messy if statements

by https://www.google.com/accounts/o8/id?id=AItOawkXhagloEt9LaGYb5TnfYmraHmMC8fzlsE, March 22, 2011 00:55, 2 refactorings, tagged with rails, controller, sphinx

This works but it's messy. ...

6b0e4504e14e6b9e239ffd1dc20f301c Talk
def notify_reply_by_email
    if !self.user.disable_emails?
    if self.root?  
...

Ruby Notify by email

by pcorral.myopenid.com, February 13, 2011 19:45, 2 refactorings, tagged with rails

how can this be better done...

82c793022ec1bce6ea7573bc27b2340b Talk
require 'open-uri'

class NewsController < ApplicationController
...

Ruby Problem with passing xml fr...

by tragicdancer.myopenid.com, January 13, 2011 19:42, 10 refactorings, tagged with rails, xmldocument, api, nokogiri

Hi!
Im trying to parse xml...

55502f40dc8b7c769880b10874abc9d0 Talk
STATES = ['address', 'shipping', 'receipt', 'confirmation']

def next_state!
...

Ruby Next Array Value

by https://www.google.com/accounts/o8/id?id=AItOawlhtGOurcXKMALBiVsK30cQwELBGpZuPXs, December 28, 2010 22:22, 4 refactorings, tagged with rails, ruby, activerecord

Trying to figure out a bett...

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 CustomersController < ApplicationController
  #GET /customers
  #GET /salons/1/customers
...

Ruby Any further refactoring can...

by Seth Archer Brown, December 20, 2010 17:52, 3 refactorings, tagged with rails

@current_salon and @current...

7766fd070ba6ab649c850da9739539d1 Talk
def display_title
  if @title.blank?
    APP_CONFIG[:site][:title]
...

Ruby Page Title Display Helper

by TimK, December 02, 2010 04:59, 10 refactorings, tagged with rails, ruby, helper

I have a helper that append...

2722012beb9afcad75df5c9f2229fd8c Talk