$ rails g model User
belongs_to
has_one
| def field_with_errors(object, method, &block) | |
| if block_given? | |
| if object.errors[method].empty? | |
| content = with_output_buffer(&block) | |
| content.html_safe | |
| else | |
| content = with_output_buffer(&block) | |
| content_tag(:span, content, :class => "field_with_errors") | |
| end | |
| end |
| # | |
| # At CoverHound, we use conditional validations all over the form. However, there is no proper way to do | |
| # this in Rails. Instead, we can provide an array of attributes (validated_fields attribute) | |
| # and ensure they are the only ones to get validated. | |
| # | |
| module ConditionalValidations | |
| attr_accessor :validated_fields | |
| def field_is_required?(field) |
| class CreateAuthentications < ActiveRecord::Migration | |
| def change | |
| create_table :authentications do |t| | |
| t.integer :user_id | |
| t.string :provider | |
| t.string :uid | |
| t.string :name | |
| t.string :oauth_token | |
| t.datetime :oauth_expires_at |
| # autoload concerns | |
| module YourApp | |
| class Application < Rails::Application | |
| config.autoload_paths += %W( | |
| #{config.root}/app/controllers/concerns | |
| #{config.root}/app/models/concerns | |
| ) | |
| end | |
| end |
| [~/.js] cat github.com.js | |
| // Hashtagify emoji | |
| $(function() { | |
| $('img.emoji').each(function() { | |
| var name = $(this).attr("title").replace(/:/g, '') | |
| if (name == '+1') { name = "thumbsup" } | |
| if (name == '-1') { name = "thumbsdown" } | |
| hashtag = $("<span>#" + name + "</span>"); | |
| hashtag.css({ color: '#000', fontWeight: 'bold' }); | |
| $(this).replaceWith(hashtag) |
| Gemfile.lock merge=bundlelock | |
| db/schema.rb merge=railsschema |
| 'use strict'; | |
| angular.module("providersApp", ["providersApp.services", "providersApp.filters", "providersApp.controllers", "ngResource", "ngRoute", "domstorage"]) | |
| .config(["$routeProvider", "$httpProvider", function($routeProvider, $httpProvider) { | |
| $routeProvider.when("/", { | |
| templateUrl: "/angular/views/providers/index.angular.html", | |
| controller: 'ProvidersCntl' | |
| }); | |
| $routeProvider.when("/details/:slug", { | |
| templateUrl: "/angular/views/providers/details.angular.html", |
| #!/bin/sh | |
| # Help output | |
| help() { | |
| echo "Usage: git-fame [options] <repository_path>" | |
| echo " -m Machine readable output" | |
| echo " -h Print this help" | |
| exit 1 | |
| } |