I see, thanks for the clarification. I actually like the simplified version better as generated email and password management is something I like to tweak most of the time.
One thing that seems to have been forgotten in the generator update/refactor: the :current_password virtual field is not being used anywhere else in the codebase.
Was taking the latest rc.2 and generators out for a spin today to learn scopes and can’t figure out how to modify the router.ex for the JSON routes so the scopes work.
Basically from a freshly generated project I ran:
mix phx.gen.auth Accounts User users
mix phx.gen.json Weather City cities name:string temperature:float
The instructions say:
Add the resource to the "/api" scope in lib/phx18_web/router.ex:
resources "/cities", CityController, except: [:new, :edit]
Ensure the routes are defined in a block that sets the `:current_scope` assign.
I uncommented out the /api code from the router and tried to add the fetch_current_scope_for_user plug to the :api pipeline but that didn’t work and my tests are failing with ** (ArgumentError) session not fetched, call fetch_session/2
pipeline :api do
plug :accepts, ["json"]
plug :fetch_current_scope_for_user # added this line
end
# Other scopes may use custom stacks.
scope "/api", Phx18Web do
pipe_through :api
resources "/cities", CityController, except: [:new, :edit]
end
I’m sure I’m missing out on something very simple here… hoping someone can help?
the fetch_current_scope_for_user plug works by fetching the user from the session. You could fetch the session similar to how the browser pipeline does it, but for an API you typically have a separate authentication mechanism. The docs have a guide on API authentication that also shows how to assign the scope in that case: API Authentication — Phoenix v1.8.0-rc.2
I took the new generators out for a spin around the block.
I ran into the following issues in GH with dependabot on a fresh install:
(Repo is private but not that hard to reproduce.)
Dependabot failed to update your dependencies because there was an error evaluating your Elixir dependency files.
Dependabot encountered the following error:
** (ArgumentError) The module Phoenix.CodeReloader was given as a child to a supervisor but it does not exist
(elixir 1.18.1) lib/supervisor.ex:797: Supervisor.init_child/1
(elixir 1.18.1) lib/supervisor.ex:905: Supervisor.child_spec/2
(elixir 1.18.1) lib/enum.ex:1714: Enum."-map/2-lists^map/1-1-"/2
(mix 1.18.1) lib/mix/pubsub.ex:77: Mix.PubSub.listener_supervisor/0
(mix 1.18.1) lib/mix/pubsub.ex:59: Mix.PubSub.start_listeners/0
(mix 1.18.1) lib/mix/tasks/deps.loadpaths.ex:74: Mix.Tasks.Deps.Loadpaths.run/1
(mix 1.18.1) lib/mix/task.ex:495: anonymous fn/3 in Mix.Task.run_task/5
(mix 1.18.1) lib/mix/tasks/loadpaths.ex:36: Mix.Tasks.Loadpaths.run/1
{"error":""}
Should I pin that version in the mix file? (which is generated with elixir: "~> 1.15".
Not sure how to let dependant know what elixir version I am using for the project.
def project do
[
listeners: listeners()
]
end
defp listeners do
if dependabot?() do
[]
else
[Phoenix.CodeReloader]
end
end
defp dependabot? do
Enum.any?(System.get_env(), fn {key, _value} -> String.starts_with?(key, "DEPENDABOT") end)
end
Just run phoenix 1.8 rc from curl https://new.phoenixframework.org/myapp | sh and faced with unstyled demo app. source code looks good, but app.css doesn’t contains tw styles. Am I wrong about something?
My app definitely have styles. watchman would not fix that, but you should install it from your distribution package manager. Tailwind-like styles should be much below those (not sure why it’s like that). Looks like you have some issue with session cookies. Please try to remove them in your browser web tools and try to refresh.
I don’t see how session cookies can affect the performance of tw. I partially fixed up the styles by editing the page template, this got the compiler to work.
Tailwind will scan every file in your project for class names, except in the following cases:
Files that are in your .gitignore file
Binary files like images, videos, or zip files
CSS files
Common package manager lock files
not for this purpose, but to see how artifacts are collected, I decided to do git init and it worked. tw relies on the presence of gitignore or something. made a new project - same problem with styles, initiate git - it works
Just for sure every error should be fixed to not investigate every possible side effect. Keep in mind that besides standards browsers like to behave differently and therefore it’s important every potential browser-specific issue.
Weird, it works for me without a git init. The .gitignore file exists in generated project, but I’m not sure that’s it …
I do not see how .git directory is supposed to help you, but I guess the .gitignore can. Please take a look at:
Maybe the Tailwind have a problem with number of watched files? I have no idea. As wrote I already tried generating project and it works out-of-the-box.