Active Admin has_many selectable list of records

JehandadK

I have been trying for days now, I am new at ROR and active admin. So far I have been able to add and delete has_many relations for a new record. And I am using strong_parameters as well as accept_nested_attributes. I want the

  • Ability to add and delete relations for existing records as well.

Ideally there should be an autocomplete box that allows searching and selection of an existing meaning for this particular model.

My models are

  • Word
  • Meaning
  • WordMeaning

I only want the capability to attach meanings that are already available to a word?

      class Word < ActiveRecord::Base    
         belongs_to :language    
         has_many :word_meanings
         has_many :meanings ,through: :word_meanings

form do |f|

f.semantic_errors *f.object.errors.keys
f.inputs do
  f.input :language
  f.input :word
  f.input :wordInScript
  f.input :pronunciation, :required => false, :as => :file
end

f.inputs do
  f.has_many :meanings, heading: 'Meanings', allow_destroy: true, new_record: true do |a|
    a.input :meaning
    a.input :language
  end
end

f.actions
end

nistvan

You can determine the collection of the select:

a.input :meaning, :as => :select, :collection => {#your collection in Hash, Array or ActiveRecord relation}.map{|key, value| [value, key] }

ActiveAdmin uses Formtastic: https://github.com/justinfrench/formtastic#usage

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Active Admin has_many selectable list of records

From Dev

Mapping `has_many` in active admin

From Dev

Active Admin - filter by presence of has_many association

From Dev

active admin sort a count of a has_many column

From Dev

Selecting 'has_many through' associations in Active Admin

From Dev

Rails 4.0.3 Active-Admin has_many checkboxes not saving

From Dev

active admin sort a count of a has_many column

From Dev

Rails 4.0.3 Active-Admin has_many checkboxes not saving

From Dev

Selecting 'has_many through' associations in Active Admin

From Dev

Can't display in Active Admin index attribute of associated model (belongs_to/has_many) - Rails 3.2

From Dev

Nested has_many resource form with Active Admin doesn't do an update

From Dev

Rails:how to show name instead of ID or Address in has_many relation in active_admin?

From Dev

Ruby On Rails Active Admin has_many dropdown to add new object

From Dev

ActiveAdmin "has_many" form duplicates when I use "active_admin/select2"

From Dev

Rails - Active Record: Find all records which have a count on has_many association with certain attributes

From Dev

Active Record how to add records to has_many :through association in rails

From Dev

ordering through an has_many relationship with a condition in rails 3 / active records / postgresql

From Dev

Rails - Active Record: Find all records which have a count on has_many association with certain attributes

From Dev

Active Admin Rails 4 has many

From Dev

Active admin has many through relation issue

From Dev

How to find records, whose has_many through objects include all objects of some list?

From Dev

Mongoid records embedded in resource in active admin are not displayed

From Dev

has_many with sum active record

From Dev

Active record has_many through filtering

From Dev

Activeadmin, duplicating has_many records

From Dev

Rails has_many through not returning records

From Dev

change text of active admin has_many_remove button?

From Dev

How to fetch records with exactly specified has_many through records?

From Dev

List all associations as links in active admin

Related Related

  1. 1

    Active Admin has_many selectable list of records

  2. 2

    Mapping `has_many` in active admin

  3. 3

    Active Admin - filter by presence of has_many association

  4. 4

    active admin sort a count of a has_many column

  5. 5

    Selecting 'has_many through' associations in Active Admin

  6. 6

    Rails 4.0.3 Active-Admin has_many checkboxes not saving

  7. 7

    active admin sort a count of a has_many column

  8. 8

    Rails 4.0.3 Active-Admin has_many checkboxes not saving

  9. 9

    Selecting 'has_many through' associations in Active Admin

  10. 10

    Can't display in Active Admin index attribute of associated model (belongs_to/has_many) - Rails 3.2

  11. 11

    Nested has_many resource form with Active Admin doesn't do an update

  12. 12

    Rails:how to show name instead of ID or Address in has_many relation in active_admin?

  13. 13

    Ruby On Rails Active Admin has_many dropdown to add new object

  14. 14

    ActiveAdmin "has_many" form duplicates when I use "active_admin/select2"

  15. 15

    Rails - Active Record: Find all records which have a count on has_many association with certain attributes

  16. 16

    Active Record how to add records to has_many :through association in rails

  17. 17

    ordering through an has_many relationship with a condition in rails 3 / active records / postgresql

  18. 18

    Rails - Active Record: Find all records which have a count on has_many association with certain attributes

  19. 19

    Active Admin Rails 4 has many

  20. 20

    Active admin has many through relation issue

  21. 21

    How to find records, whose has_many through objects include all objects of some list?

  22. 22

    Mongoid records embedded in resource in active admin are not displayed

  23. 23

    has_many with sum active record

  24. 24

    Active record has_many through filtering

  25. 25

    Activeadmin, duplicating has_many records

  26. 26

    Rails has_many through not returning records

  27. 27

    change text of active admin has_many_remove button?

  28. 28

    How to fetch records with exactly specified has_many through records?

  29. 29

    List all associations as links in active admin

HotTag

Archive