This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BootstrapFormBuilder < ActionView::Helpers::FormBuilder | |
def control_group(method, *args, &block) | |
options = args.extract_options! | |
error_class = object.errors[method].present? ? 'error' : '' | |
@template.field_set_tag(nil, class: ['control-group', error_class].join(' ')) do | |
label(method, options[:label], class: 'control-label') + | |
@template.content_tag(:div, class: 'controls') do | |
doc = Nokogiri::HTML::DocumentFragment.parse(@template.capture(&block)) | |
if help_block = doc.at_css('.help-block') | |
help_block.before inline_errors(method) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -name '*erb' | \ | |
xargs ruby -e 'ARGV.each { |i| puts "html2haml -r #{i} #{i.sub(/erb$/,"haml")}"}' | \ | |
bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install: | |
gem install haml2slim | |
Usage: | |
# haml2slim -h | |
Usage: haml2slim INPUT_FILENAME_OR_DIRECTORY [OUTPUT_FILENAME_OR_DIRECTORY] [options] | |
--trace Show a full traceback on error | |
-d, --delete Delete HAML files | |
-h, --help Show this message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MySQL. Versions 4.1 and 5.0 are recommended. | |
# | |
# Install the MySQL driver: | |
# gem install mysql2 | |
# | |
# And be sure to use new-style password hashing: | |
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html | |
development: | |
adapter: mysql2 | |
encoding: utf8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rake task to automatically run something (i.e. specs) when code files are changed | |
# By Peter Çoopér | |
# | |
# Motivation: I couldn't get autotest to run on my Sinatra project for some reason but realized | |
# it didn't require overengineering. Just detect when a file is changed and then re-run the specs! | |
# | |
# Examples: | |
# # rake on_update "rake" | |
# # rake on_update "spec spec/user_spec.rb" | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= render :partial => 'form' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
group :test do | |
# rspec goodies | |
gem 'rspec-rails' | |
# DRb server for testing frameworks | |
gem 'spork' | |
# command line tool to easily handle events on file system modifications | |
gem 'guard' | |
gem 'guard-bundler' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# / | |
guard 'bundler' do | |
watch('Gemfile') | |
end | |
guard 'spork', wait: 60, cucumber: false, rspec: true, test_unit: false do | |
watch('config/application.rb') | |
watch('config/environment.rb') | |
watch(%r{^config/environments/.+\.rb$}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# spec/spec_helper.rb | |
require 'spork' | |
Spork.prefork do | |
# Loading more in this block will cause your tests to run faster. However, | |
# if you change any configuration or code from libraries loaded here, you'll | |
# need to restart spork for it take effect. | |
# This file is copied to spec/ when you run 'rails generate rspec:install' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PostsController < ActionController::Base | |
def create | |
Post.create(post_params) | |
end | |
def update | |
Post.find(params[:id]).update_attributes!(post_params) | |
end | |
private |