dimanche 17 septembre 2017

rails array with multiple fields

I am trying to create an array that has multiple internal fields so that at the time of rendering I can save the fields of each one, something like this:

@profile = [{module:"user", Description:"module of users"},{module:"products", Description:"module of products"}]

to render and create records this way:

@profile.each do |prof|
    Record.create(module: prof.module, Description: prof.descripcion)
end

but I get this error:

NoMethodError (undefined method `module' for {:module=>"users", :description=>"module of users"}:Hash):
  app/controllers/usuarios_controller.rb:31:in `block in busqueda_usuario_perfil'
  app/controllers/usuarios_controller.rb:30:in `each'
  app/controllers/usuarios_controller.rb:30:in `busqueda_usuario_perfil'

Aucun commentaire:

Enregistrer un commentaire