[:first, :second, :third].inject({}) { |hash, key|
      hash[key] = self.send(key)
      hash
...

Ruby Hash via injectin

by papricek.myopenid.com, September 28, 2010 16:31, 3 refactorings

Hi, how to simplify this:
...

B04a553de1b8b45433b841bba440cc42 Talk
<% if controller.action_name == 'leerling' %>
<%= link_to "Voortgezet", url_for(:vopo => "vo") -%> | <%= link_to "Basis", url_for(:vopo => "po") -%>
<% end %>
...

Ruby If statement with or?

by https://www.google.com/accounts/o8/id?id=AItOawmdo5pHB7lc_C5OJPTw3EPT2380GAzewqU, September 09, 2010 15:25, 2 refactorings

I want multiple conditions ...

55502f40dc8b7c769880b10874abc9d0 Talk
def user_photo(user, values = {})
    values[:style] ||= ''
    values[:class] ||= ''
...

Ruby User thumbnail helper needs...

by Danny Peck, September 28, 2010 16:53, 1 refactoring, tagged with ruby, helper

Bit of a Ruby noob. Could u...

8f5553306c2cf7f4b14153f6117f8e9b Talk
<%= form_for :page, :url => { :action => :create } do |form| %>
<div class="tabs">
...

Ruby Rails Helper extraction

by Fu86, September 13, 2010 13:45, No refactoring

I want to make this thing m...

Ee0505bbd355292778077fb662c88f13 Talk
openid_mapping = {
  :email => ["email", "http://axschema.org/contact/email"], 
  :name => ["fullname", "http://axschema.org/namePerson"]
...

Ruby Hash + Array refactor

by Oriol, August 19, 2010 17:56, 44 refactorings, tagged with ruby, hash, array, openid, sreg, axschema

This actually works but I w...

E4679be8d7d2484f9c0b8c4df71f4d2a Talk
hash = {}
array.each { |key| hash[key] = func(key) }

Ruby How to make it more idiomatic?

by AlekSi, August 16, 2010 11:58, 6 refactorings, tagged with ruby, idiomatic, idioms

Can you make this code more...

Af19cd0c0141bf7d6b42516706eb1d1d Talk
@cart = CartItem.sum(:quantity, :group => "cart_id")
new_ids = []
@cart.each do |c|
...

Ruby Sum of the Column

by Paddy, August 21, 2010 13:49, 6 refactorings

What i want to do is, find ...

6de3daa3f91b7169c85df7702b4fb1d4 Talk
def is_translated?
    if !params[:lang].blank? and params[:lang].eq?('en')
      return true
...

Ruby too many ifs and ands

by corroded, August 09, 2010 10:25, 5 refactorings, tagged with rails ruby

there are too many if then ...

A53cdbd5cbc6e9fc944d35331a32e63c Talk
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
if @user && @user.role && @user.role.eql?('user') && @user.user_group
  @group_name = @user.user_group.name
end

Ruby Handling NoMethodError

by chipcastle.myopenid.com, August 13, 2010 17:30, 4 refactorings

It seems to me that there s...

31e2b397e15442a2d3ba42db7bd4584e Talk
sum = 0
self.items.each { |item| sum += item.fragments.count }
      
...

Ruby Calculate sum of items in a...

by FRKT, August 16, 2010 08:12, 4 refactorings, tagged with array hash

I'm pretty sure I'm not doi...

28e9d19f948f2367b2da007e7ad858fd Talk
<% 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 rails, ruby

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

Fd534d7c08b85546ce17df043ef15cd3 Talk
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, 3 refactorings, tagged with rails

I have this function in my ...

A529b78031f700ca2005bdbd1af5ee7b Talk
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
module Menus
  
  class Main_Menu
...

Ruby Help with module?!

by tragicdancer.myopenid.com, August 26, 2010 11:48, 3 refactorings

Hi Im working on a program ...

55502f40dc8b7c769880b10874abc9d0 Talk
def images
  image = Kernel.const_get(params[:class].capitalize).find_by_link(params[:id]).image
  if image.nil?
...

Ruby Rails DB Field to Image Out...

by https://www.google.com/accounts/o8/id?id=AItOawkuoairsv4fB9xuwKcC953iLBxlElFcjEA, August 18, 2010 22:19, 2 refactorings

This is a rails action that...

D41d8cd98f00b204e9800998ecf8427e Talk
class ItemsController < ApplicationController
  def create
    @product = Product.find(params[:product_id])
...

Ruby Add product to cart, reject...

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

I've a simple cart applicat...

40bae534662670583678b03fe419e3f5 Talk
def load_feeds 
  #feed url
  po = 'http://feed.kennisnet.nl/Basisonderwijs'
...

Ruby Fetch and parse feeds with ...

by https://www.google.com/accounts/o8/id?id=AItOawmdo5pHB7lc_C5OJPTw3EPT2380GAzewqU, August 23, 2010 22:18, 2 refactorings, tagged with feedzirra

Function to fetch and parse...

55502f40dc8b7c769880b10874abc9d0 Talk
module Menus
  
 def self.getValidPositiveNumber
...

Ruby Good way to output menu wit...

by tragicdancer.myopenid.com, August 30, 2010 17:28, 2 refactorings, tagged with ruby

What would be the best or a...

55502f40dc8b7c769880b10874abc9d0 Talk
class ProductsController < ApplicationController  
  helper_method :sort_column, :sort_direction
  
...

Ruby Moving Code from Controller...

by Omer Jakobinsky, August 30, 2010 12:22, 2 refactorings, tagged with rails

Hi all,
I know that the c...

Fd534d7c08b85546ce17df043ef15cd3 Talk
def include_class?(obj_class)
      stack = []
    
...

Ruby hash.include_class?, recursive

by unixcharles, August 09, 2010 00:20, 1 refactoring, tagged with short, ruby

I have a hash like this one...

23e6178f295b9cb7473d44d9e501a2b3 Talk
class MessagesController < ApplicationController
  before_filter :require_user, :only => [:new, :edit, :destroy]
  before_filter :redirect_if_doesnt_exist, :only => [:show]
...

Ruby Ruby on Rails controller re...

by https://www.google.com/accounts/o8/id?id=AItOawmw_k87TBAgAYJIdT-LlXDh4s6QvcLkk88, August 13, 2010 21:49, 1 refactoring, tagged with rails controller

What can be done to simplif...

55502f40dc8b7c769880b10874abc9d0 Talk
# Array of LDAP group names
@group_names = []

...

Ruby Refactor array of hashes

by chipcastle.myopenid.com, August 09, 2010 22:44, 1 refactoring, tagged with ruby array hash flatten select

The code below gives me wha...

31e2b397e15442a2d3ba42db7bd4584e Talk
class ModernWarfare2 < Challenge

  GAME_MODES = ['Capture the Flag', 'Demolition', 'Domination', 'Headquarters', 'Sabotage', 'Search and Destroy']
...

Ruby List of randomized items fr...

by teddyzetterlund, August 06, 2010 12:38, 1 refactoring

I've removed the code that ...

44bf7541ad28af4ae7932914c048c69c Talk
// generate code for parsing an array of array
tab = [ ["a","b"] , ["c","e"] , ["d"]]

...

Ruby Generate code for parsing a...

by bussiere, August 11, 2010 12:51, 1 refactoring, tagged with array ruby metaprogrammation parsing generation

It's dirty but it's work...

590ab8e31e515d6d8666c8b81f3a1317 Talk