Home ActiveAdmin paginate form inputs has_many
Reply: 0

ActiveAdmin paginate form inputs has_many

Milan
1#
Milan Published in 2017-11-07 10:18:02Z

I have something like this:

class Actor < ActiveRecord::Base

  attr_accessible :name, :actor_movie_relationships_attributes

  validates :name

  has_many :actor_movie_relationships, autosave: true
  has_many :movies, through: :actor_movie_relationships

  accepts_nested_attributes_for :actor_movie_relationships

end

And:

class ActorMovieRelationship < ActiveRecord::Base

  belongs_to :movie
  belongs_to :actor

  validates :movie, :actor, presence: true

end

Since Actor can have many movies, I'd like to paginate the ActiveAdmin form that is used to administer these relationships.

Currently I have this form (which is NOT paginated):

form do |f|
  tabs do
    tab 'Actor' do
      f.inputs 'Basic Information' do
        f.semantic_errors *f.object.errors.keys
        f.input :name
        f.input :deleted
      end
    end
    tab 'Movies' do
      f.inputs 'List of movies' do
        f.has_many :actor_movie_relationships, heading: '', new_record: 'Add a Movie', allow_destroy: true  do |a|
          a.input :Movie, collection: Movie.dropdown_names_map.call
        end
      end
    end
  end

  f.actions
end

Any idea how to add pagination to Movies in this form?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.3094 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO