require 'digest/md5' class List < ActiveRecord::Base
has_many :entries, -> { order('position asc') }, dependent: :destroy has_many :songs, through: :entries belongs_to :user
before_create :create_slug
validates_uniqueness_of :sharing_slug
require 'digest/md5' class List < ActiveRecord::Base
has_many :entries, -> { order('position asc') }, dependent: :destroy has_many :songs, through: :entries belongs_to :user
before_create :create_slug
validates_uniqueness_of :sharing_slug
# Given these models: | |
# | |
# Customer | |
# - name: string | |
# | |
# Product | |
# - price: integer | |
# | |
# Order | |
# - customer_id: integer |
A user's true identity or email address must be verified before they are given full access to your application.
The system sends an email to the user's email address containing a unique, personalized url. Visiting the url in a browser provides sufficient identity verification, since the url could only have been known to the person who received the email.
# you'd obviously have more settings somewhere | |
set :scm, :git | |
set :repository, "[email protected]:defunkt/github.git" | |
set :branch, "origin/master" | |
set :migrate_target, :current # this tells capistrano where to run the migration. otherwise it would try to use the latest release directory (/path/to/app/releases/2012XXXXXXXXX) | |
set :use_sudo, false | |
set :ssh_options, {:forward_agent => true} # so you can checkout the git repo without giving the server access to the repo | |
set :rails_env, 'production' | |
# These are here to override the defaults by cap |
# Python 3.4 | |
# A nice class | |
class Person: | |
def __init__(self, name): | |
self.name = name | |
# A nice function | |
def speak(): |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> | |
<script src="http://code.jquery.com/jquery-2.1.4.js"></script> |
"match_selection": false, | |
"remember_open_files": false, | |
"save_on_focus_lost": true, | |
"tab_size": 2, | |
"translate_tabs_to_spaces": true, | |
"trim_trailing_white_space_on_save": true |
import random | |
def sort(items): | |
for position in range(0, len(items)): | |
min_position_so_far = position | |
for z in range(position+1, len(items)): | |
if items[z] < items[min_position_so_far]: | |
min_position_so_far = z |
class Product | |
attr_accessor :title | |
attr_accessor :image_url | |
attr_accessor :url | |
def initialize(title, image_slug, asin) | |
@title = title | |
@url = "http://www.amazon.com/dp/#{asin}" | |
@image_url = "http://ecx.images-amazon.com/images/I/#{image_slug}._SL1500_.jpg" |
# Add this file to your config/initializers directory. | |
# | |
# Then you can do things like: | |
# | |
# Product[5] instead of Product.find_by(id: 5) | |
# Product.sample to pull a random Product row | |
# Product.sample(3) to pull three random Product rows (but they will be consecutive) | |
# | |
# Biggest part: automatic associations! | |
# |