1
2
3
4
class ProductsController < ApplicationController  
  helper_method :sort_column, :sort_direction
  
...

Ruby Moving Code from Controller...

by Omer Jakobinsky, August 30, 2010 12:22, No refactoring, tagged with rails

Hi all,
I know that the c...

A289beedc9fd9fdeaaa905bd755f6f98 Talk
1
2
3
4
<% if I18n.locale == :pl %>
    <%= link_to 'PL', { :locale => :pl }, :class => "language_selected" %> | <%= link_to 'ENG', { :locale => :en } %>
<% else %>
...

Ruby Language Selection

by Omer Jakobinsky, August 25, 2010 10:47, 3 refactorings, tagged with ruby, rails

Hi, I'm sure this is the mo...

A289beedc9fd9fdeaaa905bd755f6f98 Talk
1
2
3
4
  def format_category_list(sub_categories)
    count = sub_categories.count
    list = ""
...

Ruby Generating a list of 3 entr...

by KJF, August 24, 2010 11:15, 2 refactorings, tagged with rails

I have this function in my ...

A529b78031f700ca2005bdbd1af5ee7b Talk
1
2
3
4
uri = URI.parse(the_uri)
hash = CGI.parse(uri.query)
hash["size"] = size.to_s
...

Ruby Set value of key in uri

by Hakon1, August 21, 2010 10:59, 5 refactorings, tagged with rails

Is there some magic i don't...

3764c38cac5f613c92a87b8c3813a3ad Talk
1
2
3
4
class ItemsController < ApplicationController
  def create
    @product = Product.find(params[:product_id])
...

Ruby Add product to cart, reject...

by Arivudainambi, August 14, 2010 09:01, 2 refactorings, tagged with rails, efficiency

I've a simple cart applicat...

37f51e0d0c7a647a45c89fdf96cb4b37 Talk
1
2
3
4
    if @user.valid?
      ....
      result = create_customer
...

Ruby Redundant Else Clauses

by https://www.google.com/accounts/o8/id?id=AItOawmRvMhcLFwL72d7b-9gx7YpThiobwkY3Co, August 05, 2010 19:19, 3 refactorings, tagged with rails, conditionals

Hi,
I have a controller wh...

1772298f2d14152c13bbd3221e6ab6ec Talk
1
2
3
4
# link_categories has_many links
create_table "link_categories", :force => true do |t|
  t.string   "name"
...

Ruby Find records according to r...

by https://www.google.com/accounts/o8/id?id=AItOawl_CInyr4p6Fw9fCXT3DYEGIiMyGOQDomw, August 02, 2010 18:43, 1 refactoring, tagged with rails, ruby, activerecord, sql

I have a method (LinkCatego...

Avatar Talk
1
2
3
4
has_many :fight_wins, :class_name => 'Fight', :finder_sql =>
      '#{sanitize_sql_array(
          "SELECT f.* 
...

Ruby Refactor sanitize_sql_array

by keruilin.myopenid.com, June 20, 2010 01:31, 2 refactorings, tagged with rails, sanitize

I can't get this to work pr...

2669fbd62908cf7787bd6ac81bad624c Talk
1
2
3
class Store < ActiveRecord::Base
  has_many :promos
...

Ruby Rails Store has more than m...

by Kenzie, June 08, 2010 00:21, 1 refactoring, tagged with ruby, rails, model, associations

Store has many Promos. Prom...

0f8736dfd93c21c75ad591770a14bdb4 Talk
1
2
3
4
  def check_win_streak(streak)
    badge = 10
    while badge < BADGE::MAX_STREAK_BADGE_SIZE do # MAX_STREAK_BADGE_SIZE = 30
...

Ruby how to refactor tricky logi...

by keruilin.myopenid.com, June 06, 2010 20:32, 6 refactorings, tagged with ruby, rails, logic

The rule at work here is th...

2669fbd62908cf7787bd6ac81bad624c Talk
1
2
3
4
class IcalController < ApplicationController
  
  ##
...

Ruby iCal subscription

by MasterExplosive, June 02, 2010 10:16, No refactoring, tagged with rails, iCal

We have a database that con...

Abc6f3fa22bd75a5cd3773d50a7e91f9 Talk
1
2
3
4
def verify_admin!
    unless ((!params[:account_id].blank?) && (params[:account_id].to_i == current_account.id) && (params[:id].to_i == current_member.id)) || current_member.is_admin?
      flash[:alert] = "Can't access this page"
...

Ruby Rails Security module refac...

by jellisjapan.myopenid.com, May 14, 2010 14:28, 1 refactoring, tagged with rails

I have this method as part ...

1772298f2d14152c13bbd3221e6ab6ec Talk
1
2
3
4
last_vehicle = Vehicle.find(:first, :order => 'id desc')

unless last_vehicle.blank?
...

Ruby Ruby on Rails reverse 'build'

by sperchard.myopenid.com, May 09, 2010 12:50, 2 refactorings, tagged with rails, ruby, build

In this scenario, a new Veh...

Avatar Talk
1
2
3
4
def create
    # SWFUpload upload
    if params[:Filedata]
...

Ruby Huge create action

by Kevin Ansfield, April 29, 2010 07:53, 1 refactoring, tagged with rails, create, paperclip, swf_upload

Inherited this from an olde...

8d2495ececc02f79f0bcc39a33d1656c Talk
1
2
3
4
namespace :vic do
  desc "Bootstrap RAILS_ROOT/config/enviroment.rb"
  task :env do
...

Ruby Repeating functions in rake...

by astropanic, April 10, 2010 15:04, 4 refactorings, tagged with rails, rake

How I can remove the duplic...

A391f932c5bb61131c99f8543a07f697 Talk
1
2
3
4
class Activity < ActiveRecord::Base
  has_and_belongs_to_many :products
  has_and_belongs_to_many :articles
...

Ruby find_by in two has_and_belo...

by rduarte, March 24, 2010 21:03, 2 refactorings, tagged with ruby, rails, activerecord

Using: Article.first.products

4203bf83f438804dde849b48de826158 Talk
1
2
3
4
# Initial attributes Hash
# 
attributes = {
...

Ruby Ruby Hash Extraction Using ...

by notbrain.myopenid.com, February 24, 2010 23:13, 7 refactorings, tagged with ruby, rails, regex, hash, block

I'm looking for a better wa...

Avatar Talk
1
2
3
4
  def update_materials
    jm = JobMaterial.find(:first, :conditions => {:material_id => params[:job_material][:material_id], :job_id => params[:job_id], :location => params[:job_material][:location]})
    if jm
...

Ruby add or increment item count

by kagedwolf.myopenid.com, February 16, 2010 22:23, 2 refactorings, tagged with rails

This is a custom method in ...

3b583d1c5e2d57db5ad32ee82b56adf4 Talk
1
2
3
def render_page_sitemap(scope, sitemapname,statics, machines, lang)
...

Ruby Speeding up Sitemap generation

by tiekuhn, February 14, 2010 16:35, 3 refactorings, tagged with speed, rake, sitemap, rails

Hi,

I'm looking for a wa...

175ab087b0647367da3d370fbf5bc024 Talk
1
2
3
Clip.find_by_sql(["select * from clips where not exists
        (select 'clip_id' from histories where histories.clip_id = clips.id
        and histories.user_id = ?) ORDER BY clips.created_at DESC LIMIT 20", user.id])

Ruby ActiveRecord find_by_sql

by David, January 17, 2010 20:52, 5 refactorings, tagged with activerecord, rails, ruby, sql, short

How can I turn this into so...

Avatar Talk
1
2
3
4
class Item < ActiveRecord::Base
  ALL_VOTES = "all_votes"
  SCORE = "score"
...

Ruby Complex query in Ruby on Ra...

by Pablo, January 10, 2010 13:27, No refactoring, tagged with ruby, rails, joins, activerecord, sql

I have a method called rank...

931970b8dc51b72e05e3a12b88612d61 Talk
1
2
3
4
  def sort
    if params[:fact_id]
      @fact = Fact.find_by_id(params[:fact_id]) || Fact.new
...

Ruby Ugly IF, ELSE

by serek.openid.pl, December 18, 2009 10:17, 3 refactorings, tagged with rails, short, dry

Trying to make this a lot c...

597821ce12359ab2d95437c8164d5254 Talk
1
2
3
  def create
...

Ruby Dynamic admin with Globalize2

by Fenak, November 23, 2009 13:17, 1 refactoring, tagged with rails, i18n, globalize2

I have a multilingual admin...

D21232f63a7065c902362a61b045ed1d Talk
1
2
3
4
def merge_query!(options)
  return unless params[:query]
  statements = []
...

Ruby Merging conditions into an ...

by sferik, November 05, 2009 03:33, 2 refactorings, tagged with ruby, rails, merb

This is some controller cod...

1f74b13f1e5c6c69cb5d7fbaabb1e2cb Talk
1
2
3
4
module PrototypeFaceboxRender
  def render_to_facebox(options = {})
    options[:template] = "#{default_template_name}" if options.empty?
...

Ruby Prototype Facebox Render

by Stephane Paul, November 03, 2009 04:57, 3 refactorings, tagged with ruby, rails, facebox, prototype

I didn't want to add jQuery...

0970617d70dab1f32d8c237808e59c4d Talk