Problem with two relationships to the same table

Hi all,

When I try to save a form with two collection_select I get this error:

ActiveRecord::AssociationTypeMismatch in InscripcionController#create
Profesion expected, got String

I think that the relationship between elements is well defined, but in
this case I have two relationships leading to the same table (one for
the father and one for the mother):

class Profesion < ActiveRecord::Base
has_many :titulars_padre, :class_name=> “Titular”, :foreign_key =>
has_many :titulars_madre, :class_name=> “Titular”, :foreign_key =>

class Titular < ActiveRecord::Base
has_many :alumnos
belongs_to :profesion_padre, :class_name=> “Profesion”, :foreign_key
=> “profesion_padre_id”
belongs_to :profesion_madre, :class_name=> “Profesion”, :foreign_key
=> “profesion_madre_id”

I get the error when the execution reach this point:[:titular])

The params of the request are:

Parameters: {“commit”=>“Create”, “titular”=>{“profesion_padre”=>“10”,

Thanks in advance

Rakoon Smith wrote:[:titular])

The params of the request are:

Parameters: {“commit”=>“Create”, “titular”=>{“profesion_padre”=>“10”,

The select helpers in your view should be

<%= select :titular, :profesion_padre_id %> and
<%= select :titular, :profesion_madre_id %>, not
<%= select :titular, :profesion_padre %> and
<%= select :titular, :profesion_madre %>.

We develop, watch us RoR, in numbers too big to ignore.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs