Skip to content

Instantly share code, notes, and snippets.

defmodule Rumbl.VideoChannel do
use Rumbl.Web, :channel
def join("videos:" <> video_id, _params, socket) do
{:ok, assign(socket, :video_id, String.to_integer(video_id))}
end
def handle_info(:ping, socket) do
count = socket.assigns[:count] || 1
push socket, "ping", %{count: count}
defmodule Rumbl.UserTest do
use Rumbl.ModelCase, async: true
alias Rumbl.User
@valid_attrs %{name: "A User", username: "eva", password: "secret"}
@invalid_attrs %{}
test "changeset with valid attributes" do
changeset = User.changeset(%User{}, @valid_attrs)
assert changeset.valid?
{
"erb": {
"extends": "html",
"snippets": {
"erb": "<%= %>"
}
}
}
>> dig irc.quake.net
; <<>> DiG 9.8.3-P1 <<>> irc.quake.net
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 56425
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;irc.quake.net. IN A
=========================================================================================================
-> bookshelf git:(master) ✗ rake test
Run options: --seed 28100
# Running:
F
Finished in 0.035472s, 28.1911 runs/s, 56.3822 assertions/s.
1) Failure:
@harfangk
harfangk / gist:805250
Created February 1, 2011 01:40
authlogic deal
usersessionscontroller.rb
class UserSessionsController < ApplicationController
before_filter :require_no_user, :only => [:new, :create]
before_filter :require_user, :only => :destroy
def new
@user_session = UserSession.new
end
@harfangk
harfangk / gist:785764
Created January 19, 2011 06:02
polymorphic
class Comment < ActiveRecord::Base
belongs_to :commentable, :polymorphic => true
end
class Article < ActiveRecord::Base
has_many :comments, :as => :commentable
end
class Photo < ActiveRecord::Base
has_many :comments, :as => :commentable