Hi, in rails 3 this works out of the box. Hash style conditions defined for associations will automatically assigned as a default.
In your case you may want to exclude person_type from create and update column list, cause I do not think user should be allowed to change the value. -- Volker On Jan 3, 11:13 am, ruby_noob <[email protected]> wrote: > Hi folks > my question is how to setup some attributes when build new assosiated > record depends of assosiation? > i have 2 simple models > > class Person < ActiveRecord::Base > belongs_to :school > def to_label > "#{full_name}" > end > end > > class School < ActiveRecord::Base > has_many :teachers, :class_name => "Person", :conditions => > {:person_type => 1} > has_many :students, :class_name => "Person", :conditions => > {:person_type => 2} > end > > when i add new teacher record from school controller > school.teacher.new > > i need set teacher.person_type = 1 > > if i add student (school.student.new) i need person_type = 2 > i'm using activescaffold for adding records... -- You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails plugin" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/activescaffold?hl=en.
