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
## Rails 3.2.0 (January 20, 2012) ## | |
* Upgrade mail version to 2.4.0 *ML* | |
* Remove Old ActionMailer API *Josh Kalderimis* |
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 ErbEngine < Haml::Engine | |
def push_script(text, preserve_script, in_tag = false, preserve_tag = false, | |
escape_html = false, nuke_inner_whitespace = false) | |
push_text "<%= #{text.strip} %>" | |
end | |
def push_silent(text, can_suppress = false) | |
push_text "<% #{text.strip} %>" | |
end | |
end |
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
# 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
class PostsController < ActionController::Base | |
def create | |
Post.create(post_params) | |
end | |
def update | |
Post.find(params[:id]).update_attributes!(post_params) | |
end | |
private |
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
### /config/environment.rb | |
config.gem 'fastercsv' | |
### /config/routes.rb | |
map.connect '/users/export', :controller => 'users', :action => 'export' | |
### /app/models/user.rb | |
# find all students and pass to controller export action for export to csv | |
def self.find_students | |
find_by_sql("select students.firstname, students.lastname, students.grade, students.homeroom, students.phone, students.email, students.relationship, users.firstname, users.lastname, accounts.school from students, users, accounts where students.user_id = users.id and accounts.id = users.account_id") |
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
require 'net/http' | |
class GoogleAnalytics | |
BASE_URL = "http://www.google-analytics.com/__utm.gif?" | |
def self.create_url(request, options) | |
params = {} | |
raise(ArgumentError, "Can't create GA URL without an urchin code") unless params[:utmac] = options.delete(:ga_code) | |
raise(ArgumentError, "Can't create GA URL without a page URI") unless params[:utmp] = options.delete(:page_uri) | |
utmdt = options.delete(:description) || "-" # page description |
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
# Used to dynamically add a rails page view when using Jquery Mobile | |
# Author Nick Treadway @nicktea | |
@insert_page = (id, content) -> | |
page = $("<article id="+id+" data-role='page' data-url="+id+" data-add-back-btn='true'>" + content + "</article>") | |
page.appendTo('body') | |
$('a' + '#' + id).click -> | |
$.mobile.changePage(page, {transition: "slide"}) | |
# Use (your-view.haml) |