1 2 3 4
@team.statements.scoped({ :select => "statements.*, users.first_name", :joins => "INNER JOIN users ON users.id = statements.user_id", ...
Ruby Named Scopes in Relations
by sebastian.deutsch.myopenid.com,
June 24, 2009 15:38,
1 refactoring, tagged with rails named_scope relation
I have two models: Teams an...
1 2 3 4
def upgrade_and_restart @myvocabulary.upgrade nextmyvocabulary = Myvocabulary.draw(current_user.id, params[:position], @myvocabulary.vocabulary.lesson.proficiency.id) ...
Ruby shorten long variable names...
by dive.myopenid.com,
June 22, 2009 18:52,
5 refactorings, tagged with rails, models, variable names
I wonder how you make a lin...
1 2 3 4
class Message def initialize right_now = Time.now ...
Ruby Ruby: Date and Time methods
I have a small Ruby on Rail...
1 2 3 4
def prem(s,nx = []) return nx.join if s.empty? s.collect { |b| prem(s-[b],nx+[b]) }.flatten ...
Ruby Erlang Riddle for Rubists
Originally published at htt...
1 2 3 4
# stats is an array @popular_urls = stats.group_by{|s| s.request_uri}.sort_by {|s| s.second.size}.reverse ...
Ruby Extract method
Hello. This is from my blog...
1 2 3 4
<script type="text/javascript"> ...
Ruby cache the javascript object
by abhijeetgore.myopenid.com,
June 12, 2009 12:35,
No refactoring
Hi This question is specifi...
1 2 3 4
- @media.in_groups_of(6, false) do |group| .row = render :partial => 'media/media', :object => group[0] unless group[0].blank? ...
Ruby Iterating An Array - Need t...
I have 6 items in a row. Th...
1 2 3 4
module ActiveSupport Inflector.inflections do |inflect| inflect.plural(/$/, 's') ...
Ruby Redundant Method Calls
by reprogrammer.myopenid.com,
June 10, 2009 23:23,
2 refactorings
What is the best way to sim...
1 2 3 4
def schema raw_schema_json = ActiveSupport::JSON.decode(self.schema_json) schema = [] ...
Ruby Decoding a json object whil...
by sebastian.deutsch.myopenid.com,
June 10, 2009 18:01,
3 refactorings, tagged with ruby, rails, json
I'm decoding a json object....
1 2 3 4
class Array # insert i between each element in the array ...
Ruby Ruby: array intersperse, ef...
Intersperse is a method of ...
1 2 3 4
class User < ActiveRecord::Base has_many :assets, :foreign_key => 'creator_id' ...
Ruby Change a finder method w/ p...
by saizai.livejournal.com,
June 06, 2009 00:16,
No refactoring, tagged with rails, activerecord, associations, named_scope
How do I turn this into a h...
1 2 3
send "Unrecognized command: #{data}"
puts "Unrecognized command: #{data}"
Ruby Two lines: Same argument, ...
by claimid.com/findchris,
June 03, 2009 19:20,
4 refactorings
Is there a way to DRY this ...
1 2 3 4
module Restfulda module Helpers def logged_in_as(person, &block) ...
Ruby should_be_restful shoulda m...
by papricek.myopenid.com,
May 27, 2009 10:20,
No refactoring
I am trying to write a modi...
1 2 3 4
def self.at_beginning_of_interval(time, interval_type) #simple substraction does not (seem) to work for long intervals (summer/winter time ?) #and at_beginning_of_hour is not defined ...
Ruby At beginning of interval
This code was necessary sin...
1 2 3 4
# User.rb def most_wanted_movies ...
Ruby Is there better way to writ...
by abhijeetgore.myopenid.com,
May 23, 2009 18:44,
2 refactorings
Hay Guys
Following code...
1 2 3 4
desc "Load files from upload directory" task :load_galleries => :environment do dir = ENV["UPLOAD_DIR"] ...
Ruby Rake task to load photos fr...
I'm using the following Rak...
1 2 3 4
def process_workspaces if at_tags? at_tags.each do |at_tag| ...
Ruby Create object and many-to-m...
All this code is for doing ...
1 2 3 4
module PluginManager @plugins = [] ...
Ruby Plugin Architecture
by samnardoni.myopenid.com,
May 13, 2009 22:05,
3 refactorings, tagged with ruby, plugin, architecture
I'm trying to find a simple...
1 2 3
def create logout_keeping_session! ...
Ruby Create user, company and ro...
I need create user, company...
1 2 3 4
s = "The green hat is the twin of the green hat" h = Hash.new(0) s.split.each do |w| ...
Ruby Count words in a string
This is a coding question I...
1 2 3 4
#!/usr/bin/env ruby ARGV.map { |arg| arg.each_byte{ |b| printf "%1$08b : %1$-3d : %1$c\n", b }} ...
Ruby Binary Reference Executable
by Tj Holowaychuk,
May 02, 2009 05:53,
4 refactorings
Tinyyyyy ass program to ref...
1 2 3 4
def render_page_hierarchy(roots) html = "" roots.each do |item| ...
Ruby acts_as_nested_set menu
by papricek.myopenid.com,
May 01, 2009 13:53,
1 refactoring
Hi guys, how can be simplif...
With ruby you could use REX...