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 registration_changeset(user \\ %__MODULE__{}, attrs) do | |
user | |
|> cast(attrs, ~w(email password password_confirmation)a | |
|> validate_required(~w(email password password_confimation)a) | |
|> generate_identifier() | |
end | |
def profile_update_changeset(user, attrs) do | |
user | |
|> cast(attrs, ~w(email name)a |
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 \\ %__MODULE__{}, attrs) do | |
user | |
|> cast(attrs, ~w(email password password_confirmation)a | |
|> validate_required(~w(email password password_confimation)a) | |
|> generate_identifier() | |
end | |
defp generate_identifier(changeset) do | |
identifier = UUID.uuid1() | |
Ecto.Changeset.put_change(changeset, :identifier, identifier) |
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 insert_changeset(user \\ %__MODULE__{}, attrs) do | |
user | |
|> cast(attrs, ~w(email password password_confirmation)a | |
|> validate_required(~w(email password password_confimation)a) | |
|> generate_identifier() | |
end | |
def update_changeset(user, attrs) do | |
user | |
|> cast(attrs, ~w(email name)a) |
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 User do | |
... | |
@always_required ~w(email encrypted_password)a | |
@password_reset_allowed ~w(password new_password new_password_confirmation)a | |
@password_reset_required @always_required + ~w(password new_password)a | |
def password_reset_changeset(user, attrs) do | |
user | |
|> cast(atrs, @password_reset_allowed) | |
|> validate_required(@password_reset_required) |
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 SomeClass | |
# do something | |
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
class AppSubdomain | |
def self.matches?( request ) | |
request.subdomain == 'app' | |
end | |
end |