Matrix expected, got Fixnum && acts_as_tree?

Hello i got this:

class Matrix < ActiveRecord::Base
set_table_name :matrix

belongs_to :member, :foreign_key=>:userid
acts_as_tree :foreign_key=>:parent
end

class Member < ActiveRecord::Base
set_primary_key :userid
has_many :matrix, :foreign_key=>:userid
has_many :matrix, :foreign_key=>:parent
has_many :payment, :foreign_key=>:userid
has_many :paymentHistory, :foreign_key=>:userid
validates_presence_of :name
validates_presence_of :identification
validates_presence_of :sponsor
end

i modeled my data like this because each member have more member through
himself.

My problem is when i try to create a new member:
it says: Matrix expected, got Fixnum

but if i erase the ‘acts_as_tree’ from matrix model it works well,
what could be???

to save the data in my controller i got:

def create
@member = Member.new(params[:member])
@new_matrix = Matrix.new
respond_to do |format|
if @member.save
@new_matrix.userid = @member.userid
parent = Member.find(params[:matrix]).userid
@new_matrix.parent = parent
@new_matrix.save
flash[:notice] = ‘Member was successfully created.’
format.html { redirect_to member_url(@member) }
format.xml { head :created, :location => member_url(@member) }
else
format.html { render :action => “new” }
format.xml { render :xml => @member.errors.to_xml }
end
end
end

PLeased heeelp mee!
Best Regards,

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