Skip to content

Is there any way to add custom actions? #135

Answered by cjavdev
brunoprietog asked this question in Q&A
Discussion options

You must be logged in to vote

Put a call to member_action in your Resource that will render some HTML into the detail view of the resource.

  member_action do
    button_to "Fetch", main_app.fetch_madmin_video_path(@record), method: :patch, data: { turbo_confirm: "Are you sure?" }, class: "btn btn-primary"
  end

Put a route in your config/routes/madmin.rb routes:

  resources :videos do
    member do
      patch :fetch
    end
  end

Add the controller method to the madmin controller

    def fetch
      @record.fetch!
      redirect_to main_app.madmin_video_path(@record), notice: "Video fetched!"
    end

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@excid3
Comment options

@cjavdev
Comment options

@excid3
Comment options

@Swalden
Comment options

@excid3
Comment options

Answer selected by excid3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants