The poorly documentation saying:
action_item :view, only: :show do
link_to 'View on site', post_path(post) if post.published?
end
But it's not saying where "post" in post_path(post) coming from. I guess in this example they are adding a 'view' custom action that will execute the view member_action in the save class, and all of that only exists for show (detailed resource display). The member_action method needs the id of the resource (passed as params[:id]). First, I think that there's an error in the documentation and it should be view_post_path(...). Now, where this undocumented "post" variable coming from?
Another undocumented mystery is on the member_action example:
member_action :lock, method: :put do
resource.lock!
redirect_to resource_path, notice: "Locked!"
end
What is "resource"?
Another question:
How can I override existing actions like edit, destroy, etc?
If activeadmin wasn't ~95% undocumented it may be very useful.
You need to be aware that ActiveAdmin builds on other gems including Rails and Inherited Resources. If you are familiar with Rails (I don't recommend AA for Rails beginners) then you may recognize post_path as an auto-generated URL helper that returns a link to a hypothetical post model. This being open source you can read the specs for action item on GitHub where you will see a Post resource being registered, which is probably what Sean was thinking of when he volunteered to write this documentation.
resource
comes from the Inherited Resources gem, and you will find documentation on overriding edit, destroy, etc in its README.
I think the documentation of action_item is reasonable, if terse, and you appear to have understood most of it. If you think the documentation has an error or wish to help improve it you are welcome to volunteer a pull request. There are also various other tutorials, example apps and blog posts you may find helpful linked to from the wiki.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With