Skip to content

Commit

Permalink
Merge pull request #72 from revati/readme_fix
Browse files Browse the repository at this point in the history
Readme fix, and aligned with phx.auth.gen
  • Loading branch information
narrowtux authored Jul 14, 2021
2 parents efd2da5 + 7735fd5 commit 4433688
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ In your config.exs, write something like this:

```elixir
config :ex_audit,
ecto_repos: [MyApp.Repo],
version_schema: MyApp.Version,
tracked_schemas: [
MyApp.User,
MyApp.Accounts.User,
MyApp.BlogPost,
MyApp.Comment
]
Expand All @@ -88,13 +89,12 @@ struct. Add these under the key `:primitive_structs` in your config. So for exam

```elixir
config :ex_audit,
ecto_repos: [ExAudit.Test.Repo],
version_schema: ExAudit.Test.Version,
ecto_repos: [MyApp.Repo],
version_schema: MyApp.Version,
tracked_schemas: [
ExAudit.Test.User,
ExAudit.Test.BlogPost,
ExAudit.Test.BlogPost.Section,
ExAudit.Test.Comment
MyApp.Accounts.User,
MyApp.BlogPost,
MyApp.Comment
],
primitive_structs: [
Date
Expand Down Expand Up @@ -145,13 +145,13 @@ defmodule MyApp.Version do
field :rollback, :boolean, default: false

# custom fields
belongs_to :actor, MyApp.User
belongs_to :user, MyApp.Accounts.User
end

def changeset(struct, params \\ %{}) do
struct
|> cast(params, [:patch, :entity_id, :entity_schema, :action, :recorded_at, :rollback])
|> cast(params, [:actor_id]) # custom fields
|> cast(params, [:user_id]) # custom fields
end
end
```
Expand Down Expand Up @@ -184,7 +184,7 @@ defmodule MyApp.Migrations.AddVersions do

# optional fields that you can define yourself
# for example, it's a good idea to track who did the change
add :actor_id, references(:users, on_update: :update_all, on_delete: :nilify_all)
add :user_id, references(:users, on_update: :update_all, on_delete: :nilify_all)
end

# create this if you are going to have more than a hundred of thousands of versions
Expand Down

0 comments on commit 4433688

Please sign in to comment.