Skip to content

Instantly share code, notes, and snippets.

View tubbo's full-sized avatar
:shipit:
i don't make rails apps you use, i make the rails apps you use faster..

Tom Scott tubbo

:shipit:
i don't make rails apps you use, i make the rails apps you use faster..
View GitHub Profile

Keybase proof

I hereby claim:

  • I am tubbo on github.
  • I am tubbo (https://keybase.io/tubbo) on keybase.
  • I have a public key whose fingerprint is 36EF CE58 007F FC36 676E A414 A022 AB3D 5CEA 7017

To claim this, I am signing this object:

<%= form_for @project do |f| %>
<% if @project.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@project.errors.count, "error") %> prohibited
this project from being saved:</h2>
<ul>
<% @project.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
def insert_flash
content_tag :div, class: 'flash' do
flash.each do |name, msg|
if msg.is_a?(String)
concat( content_tag( :div, class: "fade in alert alert-#{ flash_type_to_bootstrap(name) }") do
concat( button_tag( "&times;".html_safe, class: "close", "aria-hidden" => true, "data-dismiss" => "alert" ) )
concat( content_tag :div, msg, :id => "flash_#{name}" )
end )
end
end
_team_special.html.erb
_team_normal.html.erb
_team_keith.html.erb
@tubbo
tubbo / gist:8221335
Last active January 2, 2016 00:09 — forked from anonymous/gist:8221276
%body
-if controller_name == 'home'
:javascript
$(document).on('ready page:load', function() {
Shadowbox.init();
});
def create_migration(table_name, columns="")
utc_now = Time.now.getutc.strftime("%Y%m%d%H%M%S")
class_name = table.classify.pluralize
file "db/migrate/#{utc_now}_create_#{table}.rb", %{
class Create#{class_name} < ActiveRecord::Migration
def change
create_table(:#{table_name}) do |t|
#{columns}
t.timestamps
end
Failures:
1) PostsController POST create with valid params creates a new Post
Failure/Error: expect {
count should have been changed by 1, but was changed by 0
# ./spec/controllers/posts_controller_spec.rb:47:in `block (4 levels) in <top (required)>'
2) PostsController POST create with valid params assigns a newly created post as @post
Failure/Error: assigns(:post).should be_persisted
expected persisted? to return true, got false
@tubbo
tubbo / searchable.rb
Last active December 28, 2015 19:29 — forked from anonymous/gist:7550493
def get_filters
searchable_named_columns.reduce({}) do |hash, col|
hash[col.send(:name) || col['name']] = col
end
end
def searchable_named_columns
searchable_columns.select { |col| col.respond_to? :name }
end
@tubbo
tubbo / gist:7492190
Created November 15, 2013 21:46
LITERALLY go fuck yourself Rails.
dolphin ♬ rake test --trace
** Invoke test (first_time)
** Execute test
** Invoke test:units (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
config.gem: Unpacked gem bin in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem bin in vendor/gems not in a versioned directory. Giving up.
module ElasticSearch
module RefreshIndex
extend ActiveSupport::Concern
included do
after_save :refresh_index
after_destroy :refresh_index
end
def refresh_index