Mein Modell "combobox" has_many "comboboxselects"
und "comboboxselects" belongs_to "combobox"
. Activescaffold von "Comboboxen" zeigt Daten in Comboboxselects-Spalte wie "#<Comboboxselect:0x472d25c>"
an. Wie stelle ich die Spalte "Antwort" aus der Tabelle "comboxselects" dar?ActiveScaffold - Ändern des Standardnamens des zugehörigen Objekts
Modelle:
class Combobox < ActiveRecord::Base
has_many :comboboxselects
end
class Comboboxselect < ActiveRecord::Base
belongs_to :combobox
end
Schema:
create_table "comboboxes", :force => true do |t|
t.string "question"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "comboboxselects", :force => true do |t|
t.integer "combobox_id"
t.string "answer"
t.datetime "created_at"
t.datetime "updated_at"
end
Ausgang:
class ComboboxesController < ApplicationController
active_scaffold :combobox do |config|
config.list.columns = [:id, :question]
config.columns = [:question, :comboboxselects]
end
end
class ComboboxselectsController < ApplicationController
active_scaffold :comboboxselect do |config|
config.list.columns = [:id, :combobox, :answer]
config.columns = [:answer]
end
end
Modelldateien für die beiden Modelle und ihre Schemata, bitte. – apostlion
Ich habe es hinzugefügt, Sie können es jetzt sehen. Vielen Dank für das Interesse. – kubum