automatic updating of admin controllers and views
Hello everyone.
Is there a manual or automatic update function to administrate like there is an installation routine? Or do I have to manually create controllers and views for new databases and migration updates I do?
If not, I hope this will become a feature in some version. If so, perhaps some of you can enlighten me. I read the documentation on the homepage and did not find an info on how to update dashboard controllers and views.
Kind regards,
Alexander
@Sajonara if you've made changes to your database and want to re-generate the dashboard class for a single model, you can run:
rails generate administrate:dashboard ModelName
Is that what you were looking for?
In part yes.
I changed the dashboard by hand, added the fields and when I reload the dashboard it looks fine, but when I try to edit or add a "new" resource via the dashboard the edit/new view does not resemble the changes. Maybe I missed something.
I tried to create the according views with
rails g administrate:views X
But even when I restart the rails server the new field do not show up. This _form partial has this render_field attribute in it. How do I access these attributes? Or how can I make sure that all of them are shown.
Kind regards.
P.S.: Thanks for the help so far.
@Sajonara could you paste the contents of the ModelDashboard file in question? Also, which attributes did you add to the model that aren't showing up?
@graysonwright As it turns out your tip helped.
Oh boy. I was still curious what I needed to change by hand to get to this, so I had a look into the game_dashboard.rb file which was created by administrate. As it seems, I only changed the attribute types array and the collection attributes array but forgot the form attributes array when I manually changed the file.
What I noticed though, the changes made by administrate added the elements in a different order. Is the order in the attribute types array important? Because my new field was added as last element, I added it somewhere in-between, before.
Kind regards.
Alexander
@Sajonara, glad it worked out!
The order of the ATTRIBUTE_TYPES hash isn't important - there's no rhyme or reason to where Administrate adds new attributes.