Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include hint about default admin route configuration #724

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions guides/get_started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,46 @@ end

This macro will add the required routes for the `PostLive` module. You can now access the `PostLive` LiveResource at `/admin/posts`.

### Configure a default route

To make a default route for `/admin` we recommend creating a redirect controller such as the following:

In `my_app_web/controller` create a file named `redirect_controller.ex`:

```elixir
# redirect_controller.ex

defmodule MyAppWeb.RedirectController do
use MyAppWeb, :controller

def redirect_to_posts(conn, _params) do
conn
|> Phoenix.Controller.redirect(to: ~p"/admin/posts")
|> Plug.Conn.halt()
end
end
```

And configure in your `router.ex` file:

```elixir
#router.ex

scope "/admin", MyAppWeb do

pipe_through :browser

backpex_routes()

# add this line
get "/", RedirectController, :redirect_to_posts

live_session :default, on_mount: Backpex.InitAssigns do
live_resources "/posts", PostLive
end
end
```

## Remove default background color

If you start with a new Phoenix project, you may have a default background color set for your body tag. This conflicts with the background color of the Backpex `app_shell`.
Expand Down
Loading