I followed the setup instructions, however when I go to /admin the uninitialized constant AdminController error raises. What may be causing it?
Hi Oxyrus, have you added any migration or model? This happened to me when I have an empty proyect.
No, I don't have models yet, so that is the problem, thank you!
I'm going to reopen this - if there are no models defined, we can display a helpful "Getting Started" page instead.
I don't know if it's possible at the moment but it would also be cool being able to customize the initial page too, I guess it might be considered if there's going to be a "Getting Started" page?
@picandocodigo it shouldn't be difficult to create an "admin home page". You can customize your routes file to change the generated admin root - maybe make it look something like:
namespace :admin do
DashboardManifest::DASHBOARDS.each do |dashboard_resource|
resources dashboard_resource
end
root controller: :welcome, action: :index
end
and then you can create an Admin::WelcomeController with an index action to serve up your custom homepage.
Thanks! It was pretty simple yes, just created a new Controller in the admin namespace and a new view in app/views/admin/welcome/index.html.erb. Maybe this can be added in the docs somewhere or FAQ's. I can submit a PR for that if needed (are the docs somewhere on :octocat: ?). Sorry for the OT!
No problem! The docs repo is at https://github.com/thoughtbot/administrate-docs - feel free to add some notes there. The "Customizing Controller Actions" page might be a good place.
Looks like administrate-docs is set to private.
Oops! You're right. should be open now.
:+1:
Is there a way to link to the home page from somewhere in the admin? Or create a menu nav bar for these "static pages"? I could envision more tabs with things like Admin Tasks or Stats, etc.
Is that solution suggested by @graysonwright still up to date? I'm trying to add a simple home page for my admin page by following his tips but administrate throws
uninitialized constant Welcome
I probably need to kind of disable resource auto-discovery for my Welcome controller in some way but i can't find anything about that anywhere in the docs
@mbajur I have the same problem. What I ended up doing for now is to add a dummy model, but that does not feel good at all. Did you solve the issue in another way?
I redefined app/views/administrate/application/_navigation.html.erb, and added <% if Object.const_defined?(resource.to_s.classify) %>
the final file looks like this:
<%#
# Navigation
This partial is used to display the navigation in Administrate.
By default, the navigation contains navigation links
for all resources in the admin dashboard,
as defined by the routes in the `admin/` namespace
%>
<nav class="navigation" role="navigation">
<% Administrate::Namespace.new(namespace).resources.each do |resource| %>
<% if Object.const_defined?(resource.to_s.classify) %>
<%= link_to(
display_resource_name(resource),
[namespace, resource_index_route_key(resource)],
class: "navigation__link navigation__link--#{nav_link_state(resource)}"
) %>
<% end %>
<% end %>
</nav>
you can add your custom links below like:
<%= link_to(
t('navigation.settings'),
supper_admin_edit_path,
class: "list-group-item list-group-item-action list-group-item-settings"
) %>
Ah, a duplicate of #1186. I'll go close that issue out; there's more detail here.