這是我嘗試過的。 date = Ecto.DateTime.from_erl(:calendar.universal_time())
query |> where([record], record.deadline >= ^date)
我也試過 date = Ecto.DateTime.from_erl(:calendar.universal_time())
query = from m
我想創建一個用於認證登錄的mixins,因此它可以應用於我應該可以登錄的模型。很像Ruby中的has_secure_password。 Afaik這是使用use聲明完成的,該聲明必需模塊,並調用__using__宏。所以我實現了我的mixin。 defmodule MyApp.SecurePassword do
defmacro __using__(_options) do
q
在Rails混合範圍和關聯,如果我有以下設置: class Post < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :post
def self.approved
where(approved: true)