This file contains hidden or 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 PhoenixChannels.RoomChannel do | |
use Phoenix.Channel | |
def join("rooms:lobby", auth_msg, socket) do | |
{:ok, socket} | |
end | |
def join("rooms:" <> _private_room_id, _auth_msg, socket) do | |
{:error, %{reason: "unauthorized"}} | |
end |
This file contains hidden or 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 PhoenixChannels.Router do | |
use PhoenixChannels.Web, :router | |
pipeline :browser do | |
plug :accepts, ["html"] | |
plug :fetch_session | |
plug :fetch_flash | |
plug :protect_from_forgery | |
end |
This file contains hidden or 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
mongo = Mongo.connect! | |
db = mongo |> Mongo.db("phoenix_bbs") | |
collection = db |> Mongo.Db.collection("comments") | |
# init data | |
Mongo.Collection.drop collection | |
[ | |
%{name: "hoge", title: "hoge", comment: "hogehoge"}, | |
%{name: "huge", title: "huge", comment: "hugehuge"}, | |
%{name: "darui", title: "blogger", comment: "darui"} |
This file contains hidden or 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
mongo = Mongo.connect! | |
db = mongo |> Mongo.db("phoenix_bbs") | |
collection = db |> Mongo.Db.collection("comments") | |
Mongo.Server.close(mongo) |
This file contains hidden or 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 MongoTest.Mixfile do | |
use Mix.Project | |
def project do | |
[app: :mongo_test, | |
version: "0.0.1", | |
elixir: "~> 1.0.4", | |
build_embedded: Mix.env == :prod, | |
start_permanent: Mix.env == :prod, | |
deps: deps] |
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<meta name="description" content=""> | |
<meta name="author" content=""> | |
<title>Welcome to Phoenix!</title> |
This file contains hidden or 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
<div class="jumbotron"> | |
<h2>Hello World, from <%= @messenger %>!</h2> | |
</div> |
This file contains hidden or 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 HelloPhoenix.HelloController do | |
use HelloPhoenix.Web, :controller | |
plug :action | |
def index(conn, _params) do | |
render conn, "index.html" | |
end | |
def show(conn, %{"messenger" => messenger}) do |
This file contains hidden or 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 HelloPhoenix.Router do | |
use HelloPhoenix.Web, :router | |
pipeline :browser do | |
plug :accepts, ["html"] | |
plug :fetch_session | |
plug :fetch_flash | |
plug :protect_from_forgery | |
end |
This file contains hidden or 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
<div class="jumbotron"> | |
<h2>Hello World, from Phoenix!</h2> | |
</div> |