Ich möchte eine dynamische wählen Sie die Option über Activeadmin ‚s formtastic wie so machen:Activeadmin formtastic dynamische wählen
form do |f|
f.inputs "Exam Registration Details" do
f.input :user_id, :as => :select, :collection => User.where(:admin => 'false')
#selects user from list. WORKING
f.input :student_id, :as => :select, :collection => Student.joins(lessons: :user)
#collection of students will change to students who have lessons with chosen user. NOT WORKING, returns all students who have lessons.
f.input :lesson_id, :as => :select, :collection => Lesson.joins(:student, :user)
#collection of lessons will change to reflect lessons connected by chosen user and student. NOT WORKING, returns all lessons.
end
f.buttons
end
Mein dilettantisch Code ist offensichtlich nicht funktioniert, wie ich es gedacht. Welche Änderungen sollte ich vornehmen?
Ich habe 4 Modelle wie folgt:
class Student < ActiveRecord::Base
has_many :lessons
has_many :users, through: :lessons
has_many :exam_registrations, through: :lessons
class Lesson < ActiveRecord::Base
belongs_to :user
belongs_to :student
belongs_to :exam_registration
class User < ActiveRecord::Base
has_many :lessons
has_many :students, through: :lessons
has_many :exam_registrations, through: :lessons
class ExamRegistration < ActiveRecord::Base
has_many :lessons
has_many :users, through: :lessons
has_many :students, through: :lessons
danke für die Info, das hat nach dieser kleinen Änderung für mich funktioniert. 'config.register_javascript 'exam_registrations'' – blotto
Ich bin froh, dass ich helfen konnte! –
@ Ryan.lay: können Sie bitte einen Blick auf http://stackoverflow.com/questions/28187354/active-admin-populate-one-of-the-secre-drop-down-after-first – inquisitive