ruby on rails 4 - rails_admin Change belongs_to Drop-down to Display Options from Different Field -


I rails_admin 0.6.5 with Rail 4.1.6 Sequence between the Volume and Points models is being used by has_many / related_to association setup, respectively:

  class volume  

and problem model:

  class digits < ActiveRecord :: Base is_to: Quantity, Inverse_of = & gt; : Validates: number, presence: true, numeracy: {big_than_or_equal_to: 1} valid: date, presence: true end  

rails_admin inside the interface, it works But when creating or editing a problem, the Volume drop-down menu pops up with the Volume # 1 , Volume # 2 , Volume 3 : volume_id according to those "volume numbers", not the volume : number , which is different from the ID and therefore the users are confusing.

How do I control when a problem is created or edited, which volume column is displayed in the is_to association drop-down menu? Thank you in advance for the support provided.

. An array is RailsAdmin.config.label_methods that have these properties in order of preference.

By default, they [: name ,: title]

I want to add: display_name to the front of the list so that I can easily override any model which is on DB There is a name column.

To do this, add the following line to config / initializers / rails_admin.rb

  config.label_methods.unshift (: display_name) )  

After that, in your model:

  the volume of the class  

Comments