jeudi 15 septembre 2016

Rails 3 Nested attributes get label and type dynamically

AppKey.rb

attr_accessible: :label, :key, :value, :default_value, :display_type

AppKey Table

AppKeys(id: integer, label: string, key: string, value: integer, default_value: string, display_type: string)

Example:

label: "Android Key", value: 1, default_value: "some key", display_type: "textarea"

AndroidAppKeys.rb

attr_accessbile: :app_id, :name, :value
belongs_to :app

AndroidAppKeys

AndroidAppKeys(id: integer, app_id:integer, name: integer, value: string, created_at: datetime, updated_at: datetime)

Example:

app_id:1, name: 1, value: "entered by user", created_at: datetime, updated_at: datetime

Name contains the reference of the of the AppKey table

App

(id:integer app_name:string dev_name:string)

App.rb

has_many :android_app_keys
accepts_nested_attributes :android_app_keys

I want to create nested form that should dynamically get the information AppKey table and only "value" should be saved in AndroidAppKey table.

Aucun commentaire:

Enregistrer un commentaire