Hi all,
I’m using a nested form
(#73 Complex Forms Part 1 - RailsCasts) to set up a
school + faculty user in a single form. Everything works great following
the above screencast. However, I’ve come to a temporary halt when trying
to make the first user (the same user that’s created in the nested form
along with the school) an administrator. Making the first user of the
school an admin is a requirement.
My idea of how this should work is this:
def create
@school = School.new(params[:school])
@school.faculties.admin = true
…
end
Where admin is a field (boolean) in the table and the relationship with
school (has_many :faculties) and faculty model (belongs_to :school) is
working correctly. This obviously isn’t working though. Probably because
the user isn’t created yet when trying to look for @school.faculties.
Any suggestions on how to make this work? If you need any other info
please let me know and I’ll post as soon as I can! Thanks!!
Thanks,
-Tony