Topic: RAILS SAVE IDS ARRAY

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

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

AND IN MY VIEW I HAVE:
<%=form_for @malla , :url => {:action=>"create"} do |f| %>
<table> ESCOJA EL TIPO DE MALLA
<% for c in @clase %>
<tr>
<td> <%= f.radio_button :clase_id, c.id%> <%=  c.tip_mall_descrip %></td>
</tr>
<% end %>
</table>
<br>

<table> ESCOJA EL CURSO O NIVEL
<% for n in @nivel %>
<tr>
<td> <%= check_box_tag "malla[nivel_ids][]", n.id, @malla.nivels.include?(n)%> <%=  n.nivel_numero %></td>
</tr>
<%end%>
</table>
<br>
<br>

<table> ESCOJA LA ASIGNATURA
<% for a in @asignatura %>
<tr>
<td> <%= check_box_tag "malla[asignatura_ids][]", a.id, @malla.asignaturas.include?(a)%></td>
<td><%= a.asig_nombre %></td>
</tr>
<%end%>
</table>
<br>
<%=  f.submit "GUARDAR" %>
<%end%>

My problem is, when I chose the options in my checkbox and radiobutton, I can't get their "ids" in my table ASIGNATURAS_MALLAS_NIVELS, sometimes I get this errors:

**cant convert symbol into integer or
**undefined method `stringify_keys'