RAILS GET IDS

I don't know how to solve something about a project I'm doing in Ruby on
Rails.
I want to save the IDS of my 3 models to my table DETAILS between these,
my BD is Mysql.

ASIGNATURAS--MALLAS--NIVELS-------->ASIGNATURA_ID--_MALLAS_ID--_NIVELS_ID

In the view MALLA, i list my asignaturas, mallas and niveles, and in the
controller MALLA i want to save the arrays to my model
asignaturas_mallas_nivels.

class Malla < ActiveRecord::Base
  attr_accessible :mall_estado , :clase_id, :nivel_ids, :asignatura_ids,
:nivel_id
  belongs_to :clase
  has_many :asignaturas_mallas_nivels
  has_many :asignaturas, :through => :asignaturas_mallas_nivels
  has_many :nivels, :through => :asignaturas_mallas_nivels
end

class Asignatura < ActiveRecord::Base
  attr_accessible :asig_abreviat, :asig_nombre
  has_many :distributivos
  has_many :notas
  has_many :asignaturas_mallas_nivels
  has_many :mallas, :through => :asignaturas_mallas_nivels
  has_many :nivels, :through => :asignaturas_mallas_nivels
end

class Nivel < ActiveRecord::Base
  attr_accessible :nivel_descrip, :nivel_numero, :nivele_id
  has_many :cursos
  belongs_to :nivele
  has_many :asignaturas_mallas_nivels
  has_many :mallas, :through => :asignaturas_mallas_nivels
  has_many :asignaturas, :through => :asignaturas_mallas_nivels
end

class AsignaturasMallasNivel < ActiveRecord::Base
  attr_accessible :asignatura_id, :malla_id, :nivel_id
  belongs_to :asignatura
  belongs_to :malla
  belongs_to :nivel
end

My controller is:

def new
    @asignatura = Asignatura.find(:all)
    @clase = Clase.find(:all)
    @nivel = Nivel.find(:all)
    @malla = Malla.new
  end

  def create
    params[:malla][:nivel_ids][:asignatura_ids]
    @malla = Malla.new(params[:asignatura_ids],[:nivel_ids], [:malla])
       if @malla.save
       redirect_to mallacurriculares_menu_principal_admin_path, :notice
=> 'MALLA CREADA CON EXITO'
     end
  end

You need to show us the exact error and the line of code it is failing
on (with the lines around it). First, though, have a look at the
Rails Guide on Debugging which will show you techniques that you can
use to debug your code.

Colin