Skip to content

Instantly share code, notes, and snippets.

View universal's full-sized avatar

Johannes / universa1 universal

View GitHub Profile
@universal
universal / 1 - checkout_helper.rb
Created March 20, 2012 10:18
Improve Spree's checkout step indicator
# At this checkout step indicator, all the checkout steps are turned into links. But how to
# turn *only* my completed steps into links?
#
# <jammanbo> state_machine has no memory. if you need to determine whether you have been
# in a state you need to design your machine so that that can be determined from the
# current state.
#
# ----------
#
# Expected result:
get "omnigraffle(:version)_stencils" => "home#index", as: :omni
= link_to "omni1", omni_path(:version => 1)
= link_to "omni", omni_path
<a href="/omnigraffle1_stencils">omni1</a>
<a href="/omnigraffle_stencils">omni</a>
describe "GET #new" do
before do
@user = User.new
User.stub(:new).and_return(@user)
end
it "authorizes access" do
should_authorize(:new, @user)
get :new
ned
@universal
universal / test.rb
Created October 10, 2012 12:57
parent / child super calls
class Parent
attr_accessor :something
def print
puts self.something
end
end
class Child < Parent
def print
@universal
universal / Gemfile
Created October 12, 2012 07:27
ruby parallelism
source 'https://rubygems.org'
gem 'rails', '3.2.8'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
@universal
universal / destroy.js.erb
Created October 19, 2012 10:10 — forked from anonymous/gist:3917294
ajax delete issue
$('#<%= dom_id(@match) %>').fadeOut();
require 'spec_helper'
describe "customers" do
describe "signup" do
#FactoryGirl.find_definitions
let(:user) { FactoryGirl.create(:signup_customer)}
it "has right data" do
visit signup_path
fill_in :id, :with => 2110001
@universal
universal / questionnaire.rb
Created November 9, 2012 12:44
namespaced model
# app/models/namespace/questionnaire.rb
class Namespace::Questionnaire < ActiveRecord::Base
end
@universal
universal / attendances_controller.rb
Created November 13, 2012 15:24
controller spec example with cancan
class AttendancesController < ApplicationController
before_filter :authenticate_user!
load_and_authorize_resource
def show
end
def update
@attendance.update_attributes params[:attendance]
redirect_to root_path
@universal
universal / user_totals.html.haml
Created November 14, 2012 09:17
highcharts with datetime
#user_totals_chart
:javascript
Chart = {}
Chart.series = [{
data: #{User.order("created_at").group("date(created_at)").select("count(id) as total, date(created_at) as created_at").all.map {|u| [u.created_at.to_i * 1000, u.total.to_i]}},
name: 'Benutzer'
}];
:coffeescript