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
id | |
binary_id | |
integer | |
float | |
boolean | |
string | |
binary | |
{:array, inner_type} | |
{:map, inner_type} | |
map |
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
Aptfile加入 | |
wget | |
======================= | |
m2-build.sh chmod 755,加入 | |
export HOME=/root | |
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && dpkg -i erlang-solutions_1.0_all.deb | |
apt-get update -y |
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
目標:盡可能讓使用者使用上覺得迅速。 | |
改進點:資料下載量少,下載速度快、反應速度快。 | |
Single Page Application: | |
優點 | |
1.更好的用户体验,让用户在web app感受native app的速度和流畅, | |
2.於第一次載入時將html,css,js等預先載入, | |
其後只需透過ajax(非同步載入)方式做資料的傳輸,資料傳輸量較少,只需取得資料即可展現畫面 |
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
def changeset(struct, params \\ %{}) do | |
struct | |
|> cast(params, [:house_id]) | |
|> cast_attachments(params, [:image], allow_paths: true) | |
|> validate_required([:image, :house_id]) | |
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
import Ecto.Query | |
alias YourApp.Repo | |
alias YourApp.User | |
#(這也許是一個改名字的流程) | |
#你要query user.id = 1的人 | |
#抓到這個人之後 | |
#改他的名字 | |
#更新 |
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
result = from(u in User, where: u.id == 1) |> Repo.one |> Repo.preload(:user_info) | |
result = from(u in User, where: u.id == 1, preload: [:user_info]) |> Repo.one |
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 BidhouseWeb.HouseBidController do | |
use BidhouseWeb, :controller | |
alias Bidhouse.Origins | |
alias Bidhouse.Origins.HouseBid | |
alias Bidhouse.Coherence.User | |
alias BidhouseWeb.HouseEmail | |
alias BidhouseWeb.Coherence.Mailer |
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
#... | |
@spec init(Keyword.t) :: [tuple] | |
def init(opts) do | |
login = | |
case opts[:login] do | |
true -> true | |
fun when is_function(fun) -> | |
fun | |
other -> | |
case opts[:protected] 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
def password_match(conn, _) do | |
owner = Coherence.current_user(conn) | |
house = conn.assigns[:house] | |
password = conn.params["house_bid"]["password"] | |
result = Config.user_schema.checkpw(password, Map.get(owner, Config.password_hash)) | |
if result do | |
conn | |
else |
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 BidhouseWeb.Router do | |
use BidhouseWeb, :router | |
use Coherence.Router # Add this | |
use ExAdmin.Router | |
pipeline :browser do | |
plug :accepts, ["html"] | |
plug :fetch_session | |
plug :fetch_flash | |
plug :protect_from_forgery |