4

I'm working on a project and I need to use nested form in ActiveAdmin, I'm following the docs but I think there's a bug in the latest version of ActiveAdmin. I'm using rails 4 so I need to use the gem directly from github (gem 'activeadmin', github: 'gregbell/active_admin').

Here is my code:

 form do |f|
    f.inputs "Mission" do
      f.input :level
      f.input :points
      f.input :title
      f.input :description
    end

    f.has_many :requirements do |r|
      r.input :kind, as: :select, collection: %w(text video image)
      r.input :count
      r.input :description, as: :text
    end

    f.actions
  end

and this is actually generating an "Add New Requirement" button at the bottom of the form but when I click on it the button is just taking me up to the top page (it has a # as the href value) and not generating the form.

Any help would be really appreciated. Thanks in advance

3
  • I downloaded the source code, searched for has_many.js.coffee, turned it into play JS, pasted it in a new file and included it in my manifest and it worked. Commented Apr 2, 2014 at 17:23
  • Did you add accepts_nested_attributes_for :requirements in your Mission model ? Commented Sep 23, 2014 at 10:29
  • That was 4 month ago. I dont remember. I guess that should be solved right now. Commented Sep 23, 2014 at 14:48

1 Answer 1

1

I had this problem. It doesn't automatically include the JS needed for the functionality. Try adding this in 'config/initializers/active_admin.rb':

ActiveAdmin.setup do |config|
  config.register_javascript 'active_admin/lib/has_many.js'
end
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.