1 2 3 4
class Report < ActiveRecord::Base belongs_to :reportable, :polymorphic => true ...
Ruby A shorter way to declare cl...
I added these so I could re...
1 2 3 4
if @events != nil @events.each do |event| if @recurrents != nil ...
Ruby superfluous if statements
I'm pretty sure theres a be...
1 2 3 4
def user_path(path) pre = $user_remote_pictures_paths[digest(path, $user_remote_pictures_paths.length)] "#{pre}/#{path}" ...
Ruby Same function repeated but ...
It's ugly, yes..
1 2 3 4
times.each do |time| events.each do |event| if time.strftime("%I:%M %p") == event.datetime.strftime("%I:%M %p") ...
Ruby two for loops cleanup?
times is an array of dateti...
1 2 3 4
if @foo.update_attributes(params[:foo]) and @foo.bar.update_attributes(params[:bar]) redirect_to foo_url(@parent) else ...
Ruby Saving multiple models in o...
What's the best way to save...
1 2 3 4
def tab(name, options = {}) if name == controller.controller_name.humanize || root_of_path.humanize == name content_tag :li, link_to("<span>#{name}</span>", options), :class => "active" ...
Ruby How to DRY this up
This is for a tabbed naviga...
1 2 3 4
module DashboardHelper def activity_message_for(object) case object.class.name ...
Ruby Dashboard
This works but it's kind of...
1 2 3 4
def link_to_param(text, param, values) @qs ||= {} if @qs.blank? ...
Ruby Horrible method to parse a ...
In a Rails application, I h...
1 2 3 4
def self.paged_search(query, from, category, locality, page, per_page = 10) query_str = [] query_prms = [] ...
Ruby Ferret, pagination and mult...
by jboss,
July 17, 2008 07:34,
No refactoring, tagged with rails, search, find, join, ferret, paginate
This code has multiple flaw...
1 2 3 4
class AccountsController < ApplicationController layout 'application' ...
Ruby Password update code
Mostly straight from a tuto...
1 2 3 4
xml = REXML::Document.new(data) artists = [] ...
Ruby cleaner way to limit result...
by timmyvontrimble.myopenid.com,
July 14, 2008 19:12,
9 refactorings, tagged with rails, xml, array, iteration, ruby
Wow! All of these refactori...
1 2 3 4
class Page < ActiveRecord::Base def assigned_widgets=(string) ...
Ruby Recreating a list with acts...
I tried playing with this a...
1 2 3 4
def construct_search_query query = '*' query << 'AND (' << params[:search_all] << ')' if params[:search_all] && params[:search_all].length > 3 ...
Ruby Constructing a search query
I want to construct a searc...
1 2 3 4
class Chat < ActiveRecord::Base KINDS = [[:office.l('Oficina'),0],['Personal',1]] ...
Ruby Multilingual Model Options
So far this works a treat, ...
1 2 3
<!-- THE XML IM TRYING TO PARSE --> ...
Ruby Trying to parse XML and pas...
I am completely new to ruby...
1 2 3 4
# OPTIMIZE: I think we can do a LOT for optimize this. def create added_counter = 0 ...
Ruby Importing large collection ...
This scripts get textarea w...
1 2 3
ActionController::Routing::Routes.draw do |map| eval(File.open(File.dirname(__FILE__) + '/../path/to/another/routes/file.rb', 'r').read) end
Ruby Adding routes in an externa...
I'm trying to retain the ra...
1 2 3 4
# in lib/product_scraper/base.rb class ProductScraper::Base def product_pages ...
Ruby OO Ruby help, por favor
This is really my first att...
1 2 3 4
<table class="charge"> <tr> <td colspan="100%" class="mainHeader"><%=@label.label%></td> ...
Ruby Iterating through a nested ...
by mwilliams,
January 31, 2008 18:21,
2 refactorings, tagged with rails, view, table, hash, nested hash, iterator, iterate, ruby, Ruby on Rails
Good afternoon. I have a n...
1 2 3
@a_to_z = Service.find(:all,:select=>'SUBSTR(name,1,1) AS letter',:group=>'SUBSTR(name,1,1)',:order=>'name').collect { |d| d.letter } ...
Ruby A to Z only linking to lett...
by aubergene,
January 13, 2008 21:10,
1 refactoring, tagged with Ruby on Rails, rails, alphabet, a to z
I wanted A to Z anchor link...
1 2 3 4
def planned_percent_complete if self.planned_complete_in_dollars != nil (( self.planned_complete_in_dollars.to_f / self.task.budget.to_f ) * 100).round(2) ...
Ruby Same methods, different Act...
I know there has to be a "r...
1 2 3 4
def self.find_matches(params) matches = self.find(:all) ...
Ruby Filtering Method Needs to b...
by bradly.myopenid.com,
January 04, 2008 16:38,
No refactoring, tagged with ruby, rails, filtering, wet
I know it looks long, but i...
1 2 3 4
before: def list_for_blogentries(user) ...
Ruby Refactor my blog item helper
I have a helper to show all...
In a Rails controller I'm s...