Tôi muốn thực hiện một lựa chọn tùy chọn động thông qua formtastic Activeadmin 's như vậy:Activeadmin động formtastic chọn
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
đang nghiệp dư của tôi là rõ ràng không phải làm việc như tôi dự định nó. Tôi nên thay đổi những gì?
Tôi có 4 mô hình như sau:
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
cảm ơn thông tin, điều này làm việc cho tôi sau sự thay đổi nhỏ này. 'config.register_javascript 'exam_registrations'' – blotto
Vui vì tôi có thể giúp! –
@ Ryan.lay: bạn có thể vui lòng xem http://stackoverflow.com/questions/28187354/active-admin-populate-one-of-the-second-drop-down-after-first – inquisitive