Skip to content

Instantly share code, notes, and snippets.

def date=(date)
write_attribute(:date, date.gsub(/(\d{4})\/(\d{2})\/(\d{2})/, "#{$3}/#{$2}/#{$1}"))
end
@rafarubert
rafarubert / intall_flavao
Created March 30, 2011 22:28
Instalação pro Flavão
apt-get install build-essential zlib1g-dev libssl-dev libreadline5-dev
sudo apt-get install ruby-full libmysql-ruby librmagick-ruby build-essential
apt-get install git-core
wget http://rubyforge.org/frs/download.php/74445/rubygems-1.6.2.tgz
@rafarubert
rafarubert / gist:950028
Created April 30, 2011 21:53
accepts_nested_attributes_for + factoryGirl
#antes:
Factory.define :bunch , :class => Bunch do |f|
f.ribbon_color_id 1
f.production_unit_id 1
f.release "2011-01-12 22:37:49"
f.user_id 1
end
Factory.define :lot, :class => :Lot do |f|
f.production_unit_id 1
@rafarubert
rafarubert / gist:977551
Created May 17, 2011 22:22
Factory Exemplo
#bunch.rb
Factory.define :bunch , :class => Bunch do |f|
f.ribbon_color {|ribbon_color|ribbon_color.association(:ribbon_color) }
f.date "2011-01-12 22:37:49"
f.user_id 1
f.after_build { |f|
f.bunch_lots << Factory.build(:bunch_lot)
}
end
Factory.define :lot, :class => Lot do |f|
@rafarubert
rafarubert / gist:983942
Created May 20, 2011 22:31
jquery_radio
$(".radioTag").bind("ready load change",function(){
if ($("input[@name='rdio']:checked").val() == 'fisica'){
$("#fisica").show();
$("#juridica").hide();
}else if ($("input[@name='rdio']:checked").val() == 'juridica'){
$("#fisica").hide();
$("#juridica").show();
}
});
@rafarubert
rafarubert / gist:1034998
Created June 20, 2011 01:33
teste capybara
#encoding: utf-8
require 'acceptance/acceptance_helper'
include HelperMethods
feature "Marcando Consulta", %Q{
como um atendente
} do
before(:each) do
#!/usr/bin/env bash
ruby_string="1.9.2"
gemset_name="egenda"
if rvm list strings | grep -q "${ruby_string}" ; then
# Load or create the specified environment
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
&& -s "${rvm_path:-$HOME/.rvm}/environments/${ruby_string}@${gemset_name}" ]] ; then
$(function(){
var _new_li = new String();
var _element = new Object();
$( "#draggable > li" ).draggable({ revert: true });
$( "#droppable").droppable({
accept: "#draggable > li",
drop: function(event, ui){
console.log(ui);
_new_li = $('<li>'+ui.draggable.context.innerHTML+'<input name="campaign[employee_ids][]" type="hidden" value="'+ui.draggable.context.id+'" /> <span><img src="/assets/cancel.jpg" alt="Remover" title="Remover"></span></li>')
@rafarubert
rafarubert / gist:1069627
Created July 7, 2011 14:27
calendario baseado has_Calendar
#encoding: utf-8
module Atendente::AgendaHelper
def calendar(options={}, &block)
options = {
:events => nil,
:field => :created_at,
:header_format => :week,
:id => "calendar",
:month => Date.today.month,
:today => nil,
development:
adapter: postgresql
encoding: utf8
database: egenda_development
username: ruby
password: ruby
production:
adapter: postgresql
encoding: utf8