rubyruby-on-rails-3activeadminformtastic

Adding custom form actions in ActiveAdmin


I'm using ActiveAdmin to add google OAuth credentials to a record. The client ID and Client Secret are added via record/1/edit, and I use those to generate a link to allow access. This link appears in record/view. I am trynig to find a way for the Administrator to enter the code returned by google oauth into the portal so that I can use it to generate credentials.

My current attempt looks something like this

row "Code from Google OAuth" do form do |f| label "Google Auth Code:" input :code, :label => "Code", :hint => "Code returned by google auth" f.action :submit end

I get an "undefined method: action" error form this code. Any ideas on how to return user input as a parameter?


Solution

  • form is an Arbre tag that maps directly to HTML, in which case action is an attribute, eg.

    form(action: '/someroute', method: :patch) do ... end
    

    If you want to embed a Rails or Formtastic form you would use form_for or active_admin_form_for respectively.