Replacing Rails' default form builder with a custom form builder is a typical way of adding custom form helpers to a Rails application.
The typical way of doing this is:
ActionView::Base.default_form_builder = MyCustomFormBuilder
| module RSpec | |
| module Core | |
| module Hooks | |
| def because(*args, &block) | |
| scope, options = scope_and_options_from(*args) | |
| hooks[:after][scope] << AfterHook.new(options, &block) | |
| end | |
| end | |
| end | |
| module Mocks |
Replacing Rails' default form builder with a custom form builder is a typical way of adding custom form helpers to a Rails application.
The typical way of doing this is:
ActionView::Base.default_form_builder = MyCustomFormBuilder
| function changes { | |
| start="$1" | |
| end="$2" | |
| if [ -z "$2" ]; then | |
| start="$1"^ | |
| end="$1" | |
| fi | |
| if [ -z "$1" ]; then |
| def submit_button(options={}) | |
| text = options.delete(:text) || "Submit" | |
| options.merge! :type => :submit | |
| capture_haml do | |
| haml_concat(content_tag(:button, options) do | |
| haml_concat content_tag(:span, text) | |
| end) | |
| end | |
| end |
| # Add your own tasks in files placed in lib/tasks ending in .rake, | |
| # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | |
| require File.expand_path('../config/application', __FILE__) | |
| require 'rake' | |
| module ::Restbuy | |
| class Application | |
| include Rake::DSL | |
| end |
| require 'rubygems' | |
| require 'mongo' | |
| db = Mongo::Connection.new.db("hack") | |
| db['hack'].insert(:created_at => BSON::Timestamp.new(nil,nil)) |
| module RSpec | |
| module Core | |
| module Hooks | |
| def act(*args, &block) | |
| scope, options = scope_and_options_from(*args) | |
| hooks[:before][scope] << BeforeHook.new(options, &block) | |
| end | |
| def act_after(*args, &block) | |
| scope, options = scope_and_options_from(*args) | |
| hooks[:after][scope] << AfterHook.new(options, &block) |
| class Thing | |
| include Configured | |
| setting :some_setting | |
| setting :other_setting | |
| end | |
| class Configuration | |
| def some_setting | |
| 'foo' |
| class Foo | |
| attr_accessor :bar | |
| end | |
| foo = Foo.new | |
| foo.bar = 'blah' | |
| transformer = Transformer.build :foo | |
| transformed_foo = transformer.transform foo |
| module M | |
| def foo | |
| puts "M#foo" | |
| end | |
| end | |
| class C | |
| end | |