Skip to content

Instantly share code, notes, and snippets.

once_a_day(:thursday) do
puts 'hello'
end
def add3(a)
a + 3
end
a = add3(3)
puts a #this would put out six
=form_for [@user,@book,@page] , :url => user_book_pages_path(@user.name,@book.number) do |f|
%p
= f.label :link
= f.text_field :link
%p
= f.label :summary
= f.text_area :summary
%p
= f.submit
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
-- Table: pages
-- DROP TABLE pages;
CREATE TABLE pages
(
id serial NOT NULL,
title character varying(255),
link character varying(255),
summary text,
[5] pry(main)> b = Book.find(14)
Book Load (0.4ms) SELECT "books".* FROM "books" WHERE "books"."user_id" = 2 AND "books"."id" = $1 LIMIT 1 [["id", 14]]
=> #<Book id: 14, title: "Example", summary: "This is what we have so far.", user_id: 2, created_at: "2013-06-01 18:49:21", updated_at: "2013-06-01 18:49:21">
[6] pry(main)> b.pages.last
Page Load (0.7ms) SELECT "pages".* FROM "pages" WHERE "pages"."book_id" = 14 ORDER BY "pages"."id" DESC LIMIT 1
=> #<Page id: 6, title: "rubyonrails.org", link: "http://rubyonrails.org/", summary: "This is the framework I'm using.", book_id: 14, created_at: "2013-06-01 18:53:35", updated_at: "2013-06-01 18:53:35">
[7] pry(main)> b.pages.first
Page Load (0.4ms) SELECT "pages".* FROM "pages" WHERE "pages"."book_id" = 14 LIMIT 1
=> #<Page id: 6, title: "rubyonrails.org", link: "http://rubyonrails.org/", summary: "This is the framework I'm using.", book_id: 14, created_at: "2013-06-01 18:53:35", updated_at: "2013-06-01 18:53:35">
[8] pry(main)> b.pages.all
class Page < ActiveRecord::Base
belongs_to :book
attr_accessible :link, :summary, :title
before_save :set_title
def set_title
self.title ||= URI.parse(URI.encode(self.link.strip)).host
self.title ||= self.link
end
end
class UserController < ApplicationController
def index
end
def show
end
def new
@user = User.new
end
= form_for :user, url: user_path do |f|
%p
= f.label :name
= f.text_field :name
%p
= f.label :favorite_number
= f.text_field :favorite_number
%p
= f.label :bio
= f.text_area :bio
@Benjmin
Benjmin / gist:4750539
Created February 10, 2013 18:37
The keyboard isn't affecting it at all
function love.load()
kevin = {}
kevin.hearts = 3
kevin.attack = "nothing"
kevin.charge = 1
kevin.decided = false
enemy = {}
enemy.hearts = 3
enemy.attack = "nothing"
enemy.attack_phase = 1