Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure the label of Active Admin has_many

Well I have a two models related with a on-to-many assoc.

#models/outline.rb
    class Outline < ActiveRecord::Base
      has_many :documents
    end

#models/document.rb
    class Document < ActiveRecord::Base
      belongs_to :outline
    end

#admin/outlines.rb
    ActiveAdmin.register Outline do
      form do |f|
        f.inputs "Details" do
          f.input :name, :required => true
          f.input :pages, :required => true
          ...
          f.buttons
        end
        f.inputs "Document Versions" do 
          f.has_many :documents, :name => "Document Versions"  do |d|
            d.input :file, :as => :file
            d.buttons do
              d.commit_button :title => "Add new Document Version"
            end
          end
        end
      end
    end

Well as you can see in the admin/outlines.rb I already tried setting up the :name, in the has_many :documents, and the :title in the commit_button, but neither of that options work, I also tried with :legend, :title, and :label, instead of :name in the .has_many. Not working.

This is the result of that code: Screenshot

What I want to display is "Document Versions" instead of "Documents", and "Add new Document Version" instead of "Add new Document"

If someone can have a solution it would be great

like image 428
MatisMasters Avatar asked Nov 29 '11 12:11

MatisMasters


1 Answers

To set has_many header you can use

f.has_many :images, heading: 'My images' do |i|
  i.input :src, label: false
end

See here

like image 177
timfjord Avatar answered Oct 19 '22 05:10

timfjord