This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
========================================================================================================= | |
-> 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"erb": { | |
"extends": "html", | |
"snippets": { | |
"erb": "<%= %>" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test/models/user_repo_test.ex | |
defmodule Storybook.UserRepoTest do | |
use Storybook.ModelCase | |
import Storybook.Factory | |
alias Storybook.User | |
@valid_attrs %{email: "[email protected]", username: "user", password: "password"} | |
@test_attrs %{email: "[email protected]", username: "different_user", password: "different_password"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
==================================================================================== | |
new test: | |
test "converts unique_constraint on username to error" do | |
%User{} | |
|> User.registration_changeset(@valid_attrs) | |
|> Repo.insert!() | |
Repo.all(User) | |
|> IO.inspect() | |
attrs = Map.put(@test_attrs, :username, "user") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
web/static/js/video.js | |
========================================================================================================= | |
/*** | |
* Excerpted from "Programming Phoenix", | |
* published by The Pragmatic Bookshelf. | |
* Copyrights apply to this code. It may not be used to create training material, | |
* courses, books, articles, and the like. Contact us if you are in doubt. | |
* We make no guarantees that this code is fit for any purpose. | |
* Visit http://www.pragmaticprogrammer.com/titles/phoenix for more book information. | |
***/ |
OlderNewer