Skip to content

Instantly share code, notes, and snippets.

View clemens's full-sized avatar
:octocat:
Getting sh*t done

Clemens Kofler clemens

:octocat:
Getting sh*t done
View GitHub Profile
class ArticleFormBuilder < ExtensibleFormBuilder
after(:article, :author_id) do |f|
f.field_set do
<<-html
#{ f.text_field(:teaser_title, :label => true) }
#{ f.text_field(:teaser_subtitle, :label => true) }
#{ f.text_field(:teaser_image_url, :label => true) }
#{ f.text_area(:teaser_text, :label => true, :class => 'short') }
html
end
require 'rubygems'
require 'activesupport'
module ActionController
end
class ActionController::Base
end
module ActionController::Helpers
local:~/ clemens$ sudo jgem install rspec --no-ri --no-rdoc
/opt/local/jruby/bin/jgem: line 8: require: command not found
/opt/local/jruby/bin/jgem: line 9: require: command not found
/opt/local/jruby/bin/jgem: line 10: require: command not found
/opt/local/jruby/bin/jgem: line 12: required_version: command not found
/opt/local/jruby/bin/jgem: line 14: unless: command not found
/opt/local/jruby/bin/jgem: line 15: abort: command not found
/opt/local/jruby/bin/jgem: line 16: end: command not found
/opt/local/jruby/bin/jgem: line 18: args: command not found
/opt/local/jruby/bin/jgem: line 20: begin: command not found
# Ruby on Rails Developer, Berlin/Potsdam
describe "Job: Ruby on Rails Developer(m/f)" do
before do
we = Company.new(
:name => 'adva Business Software GmbH',
:website => 'http://adva-business.com',
:email => 'info@adva-business.com'
)
you = Developer.new
job = Job.new(we, you, :title => "Ruby on Rails Developer", :location => "Berlin/Potsdam")
Object.class_eval do
def fucking
self
end
end
20.fucking.minutes.from_now
# Domtastic Cucumber
#
# domesticate your Cucumber
#
# written by Clemens Kofler <clemens@railway.at>
# http://www.railway.at
# http://github.com/clemens
#
# see http://www.railway.at/articles/2009/09/12/using-cucumber-to-test-a-multilingual-app
# for reasons why this might be what you need ;-)
# no need to override human_attribute_name to customize error messages ...
# http://wgibbs.github.com/2009/10/27/human-attribute-name.html
en:
activerecord:
attributes:
user:
permissions: 'Reuse settings'
@clemens
clemens / gist:291108
Created January 31, 2010 15:14
Statistics problem
+------+--------+------------------------+------------+
| City | People | Spending power (total) | Sold units |
+------+--------+------------------------+------------+
| A | 10 | 200,000 | 30 |
| B | 5 | 150,000 | 25 |
| C | 5 | 50,000 | 20 |
| D | 25 | 400,000 | 35 |
+------+--------+------------------------+------------+
To do:
class Post < ActiveRecord::Base
scope :published, where(:published => true)
scope :published, :conditions => { :published => true }
end
# the first one fails when loading the environment (e.g. when migrating the database), if the posts table doesn't exist
# the second one (always) works, independent of whether or not the table exists
# ... or so it seems ...
###################################
# I'm a pretty comment with style #
###################################