Terryble
Terryble
AEAsh Elixir
Created by Terryble on 7/13/2023 in #support
many_to_many exception after updating Ash
Ah. Sorry, I was confused. So the join relationship now needs to be stated explicitly similar to Rails. Thanks for helping!
8 replies
AEAsh Elixir
Created by Terryble on 7/13/2023 in #support
many_to_many exception after updating Ash
This is working in my app in its current state. When I tried updating all of the Ash-related libraries to the latest version, I am now getting this exception
8 replies
AEAsh Elixir
Created by Terryble on 4/23/2023 in #support
How to do polymorphic relationships, but with only 1 table?
Thanks! Looks like I have to give it some more thought then
7 replies
AEAsh Elixir
Created by Terryble on 4/13/2023 in #support
How to filter associations when preloading them?
That worked! Thanks!
4 replies
AEAsh Elixir
Created by Myrmyr on 2/9/2023 in #support
Ash stopped working with ExMachina. Ash 2.5.10
I tried Ash.Seed and it looks like it's enough for me. I wish I'd known about that module a lot earlier lol
29 replies
AEAsh Elixir
Created by Myrmyr on 2/9/2023 in #support
Ash stopped working with ExMachina. Ash 2.5.10
It doesn't exist even inside the test. As in the struct says it's loaded, but there is no id, inserted_at, and updated_at which implies the record didn't get created.
29 replies
AEAsh Elixir
Created by Myrmyr on 2/9/2023 in #support
Ash stopped working with ExMachina. Ash 2.5.10
I didn't know Ash.Seed exists. I'll check this out. Thanks!
29 replies
AEAsh Elixir
Created by Myrmyr on 2/9/2023 in #support
Ash stopped working with ExMachina. Ash 2.5.10
Not sure if anything changed recently, but I tried this solution and it doesn't work for some reason. None of the records I try to create are persisted in the database.
29 replies
AEAsh Elixir
Created by Terryble on 4/4/2023 in #support
How to test LiveView behind AshAuthentication?
Holy crap, that worked! I wonder why the AshHQ repo didn't have to do that to make it work on the tests.
4 replies
AEAsh Elixir
Created by Terryble on 4/4/2023 in #support
How to test LiveView behind AshAuthentication?
I hit the character limit in my initial post. This is the continuation:
defmodule MyApp.AccountsFixtures do
alias Terrible.Authentication.User

def user_fixture(attrs \\ %{}) do
password = Map.get(attrs, :password, "password123")

user =
User.register_with_password!(
Map.get(attrs, :email, "[email protected]"),
password,
password,
authorize?: false
)

receive do
{:email, _} -> :ok
after
0 -> :ok
end

user
end
end
defmodule MyApp.AccountsFixtures do
alias Terrible.Authentication.User

def user_fixture(attrs \\ %{}) do
password = Map.get(attrs, :password, "password123")

user =
User.register_with_password!(
Map.get(attrs, :email, "[email protected]"),
password,
password,
authorize?: false
)

receive do
{:email, _} -> :ok
after
0 -> :ok
end

user
end
end
defmodule MyAppWeb.Router do
use MyAppWeb, :router
use AshAuthentication.Phoenix.Router

pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, {MyAppWeb.Layouts, :root}
plug :protect_from_forgery
plug :put_secure_browser_headers
plug :load_from_session
end

pipeline :api do
plug :accepts, ["json"]
plug :load_from_bearer
end

scope "/", MyAppWeb do
pipe_through :browser

get "/", PageController, :home

sign_in_route()
sign_out_route(AuthenticationController)
auth_routes_for(MyApp.Accounts.User, to: AuthenticationController)
reset_route([])

live_session :authenticated,
on_mount: [
AshAuthentication.Phoenix.LiveSession,
{MyAppWeb.LiveUserAssigns, :live_user_required}
],
session: {AshAuthentication.Phoenix.LiveSession, :generate_session, []} do
live "/books", BookLive.Index, :index
end
end
end
defmodule MyAppWeb.Router do
use MyAppWeb, :router
use AshAuthentication.Phoenix.Router

pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, {MyAppWeb.Layouts, :root}
plug :protect_from_forgery
plug :put_secure_browser_headers
plug :load_from_session
end

pipeline :api do
plug :accepts, ["json"]
plug :load_from_bearer
end

scope "/", MyAppWeb do
pipe_through :browser

get "/", PageController, :home

sign_in_route()
sign_out_route(AuthenticationController)
auth_routes_for(MyApp.Accounts.User, to: AuthenticationController)
reset_route([])

live_session :authenticated,
on_mount: [
AshAuthentication.Phoenix.LiveSession,
{MyAppWeb.LiveUserAssigns, :live_user_required}
],
session: {AshAuthentication.Phoenix.LiveSession, :generate_session, []} do
live "/books", BookLive.Index, :index
end
end
end
I'm getting this error when running the test:
** (MatchError) no match of right hand side value: {:error, {:redirect, %{flash: %{}, to: "/sign-in"}}}
code: {:ok, _index_live, html} = live(conn, ~p"/books")
** (MatchError) no match of right hand side value: {:error, {:redirect, %{flash: %{}, to: "/sign-in"}}}
code: {:ok, _index_live, html} = live(conn, ~p"/books")
4 replies
AEAsh Elixir
Created by Terryble on 3/7/2023 in #support
How to use AshPhoenix.Form with the default core_components file that comes with Phoenix 1.7?
That worked! I realized I was wrong because I was trying to follow the way the new generators in 1. 7 did it. Apparently, all I had to do was update ash_phoenix to the latest version. and that was it. Thanks!
7 replies
AEAsh Elixir
Created by Terryble on 3/7/2023 in #support
How to use AshPhoenix.Form with the default core_components file that comes with Phoenix 1.7?
I forked ash_phoenix and I did some testing. My guess was correct - submit/2 was indeed returning {:ok, Ash.Resource.record()} so the call to Phoenix.HTML.FormData.to_form/1 will not work. I'm not sure if I just did it wrong or if this is an actual bug.
7 replies
AEAsh Elixir
Created by Terryble on 3/7/2023 in #support
How to use AshPhoenix.Form with the default core_components file that comes with Phoenix 1.7?
I'm just guessing here. I'm looking at the source for AshPhoenix.Form.submit and it looks like submit/2 is returning {:ok, Ash.Resource.record()} which breaks the call to Phoenix.HTML.FormData.to_form/1. I'm not 100% and it's just based on how I understood the source code for this. https://github.com/ash-project/ash_phoenix/blob/v1.2.8/lib/ash_phoenix/form/form.ex#L1434
7 replies
AEAsh Elixir
Created by Terryble on 3/2/2023 in #support
How to set a default value for AshPhoenix.Form.for_action ?
This is so detailed. Thanks for helping!
7 replies
AEAsh Elixir
Created by Terryble on 2/28/2023 in #support
How to do the LiveComponent preload example in Ash.Query?
Alright. Thanks!
6 replies
AEAsh Elixir
Created by Terryble on 2/28/2023 in #support
How to do the LiveComponent preload example in Ash.Query?
So instead of doing a select, just execute the query normally and then use Map.new to produce the same result as the example above?
6 replies
AEAsh Elixir
Created by Terryble on 2/26/2023 in #support
AshPhoenix.Form for an Ash.Flow module instead of Ash.Resource
That would be dope
6 replies
AEAsh Elixir
Created by Terryble on 2/26/2023 in #support
AshPhoenix.Form for an Ash.Flow module instead of Ash.Resource
Cool. I was just checking. Thanks!
6 replies
AEAsh Elixir
Created by Terryble on 2/26/2023 in #support
AshPhoenix.Form for an Ash.Flow module instead of Ash.Resource
I understand I can just do AshPhoenix.Form.validate and then manually call my Ash.Flow module instead of calling AshPhoenix.Form.submit. I was just wondering if there's a direct way of calling the Ash.Flow module.
6 replies
AEAsh Elixir
Created by Terryble on 2/24/2023 in #support
Where and how do I write my business logic?
Alright. Thanks!
14 replies