hola a todos por aqui…
Quisiera que algien me ayudara con este problema…
tengo un chec_box_tag que no puedo hacerlo funcionar en la actualizacion
pero si funciona en la creacion de nuevos registros
mis tablas son las siguientes
ucurrics
CREATE TABLE ucurrics
(
id
int(10) unsigned NOT NULL auto_increment,
campus_id
char(1) NOT NULL,
email
char(64) NOT NULL,
nombreCompleto
char(32) NOT NULL,
telefono
char(30) NOT NULL,
fax
char(30) NOT NULL,
web
char(64) NOT NULL,
tituloAnuncio
char(64) NOT NULL,
descripcion
text NOT NULL,
curriculum
text NOT NULL,
residencia
char(32) NOT NULL,
edad
char(2) NOT NULL,
nivelEstudios
char(2) NOT NULL,
situacionLaboral
char(2) NOT NULL,
disponibilidad
char(2) NOT NULL,
expProfesional
char(2) NOT NULL,
nivelIngles
char(2) NOT NULL,
estadoCivil
char(2) NOT NULL,
sexo
char(2) NOT NULL,
expectativaSalar
char(10) NOT NULL,
tipoDeEmpleo
varchar(100) NOT NULL,
catProfesional
char(128) NOT NULL,
ubicacion
char(128) NOT NULL,
fechaDeRegistro
datetime default NULL,
PRIMARY KEY (id
)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=19 ;
vtipodeempleos
CREATE TABLE vtipodeempleos
(
id
int(10) unsigned NOT NULL auto_increment,
desplegar
char(36) NOT NULL,
valor
char(2) NOT NULL,
PRIMARY KEY (id
)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
Con estos datos
INSERT INTO vtipodeempleos
(id
, desplegar
, valor
) VALUES
(1, ‘CUALQUIERA’, ‘00’),
(2, ‘TIEMPO COMPLETO’, ‘01’),
(3, ‘MEDIO TIEMPO’, ‘02’),
(4, ‘POR HORAS’, ‘03’),
(5, ‘TEMPORAL’, ‘04’),
(6, ‘BECA/PRACTICAS’, ‘05’),
(7, ‘DESDE CASA’, ‘06’);
los modelos son los siguientes
models/ucurric.rb
class Ucurric < ActiveRecord::Base
has_and_belongs_to_many :vtipodeempleos
end
y
models/vtipodeempleo.rb
class Vtipodeempleo < ActiveRecord::Base
has_and_belongs_to_many :ucurrics
end
en el archivo ucurrics/_form.rhtml ingrese lo siguiente
<% for vtipodeempleo in Vtipodeempleo.find(:all) %>
Ahora en la opcion new funciona correctametne y se almacenan los datos
bien en la base de datos…
pero el problema es cuando quiero editar el registro obtengo este error
y no se donde se encuentra
Showing app/views/ucurrics/_form.rhtml where line #65 raised:
Mysql::Error: Table ‘bt.ucurrics_vtipodeempleos’ doesn’t exist: SHOW
FIELDS FROM ucurrics_vtipodeempleos
Extracted source (around line #65):
62:
63: <% for vtipodeempleo in Vtipodeempleo.find(:all) %>
64:
65: <%= check_box_tag “ucurric[tipoDeEmpleo][]”, vtipodeempleo.id,
@ucurric.vtipodeempleo.include?(vtipodeempleo) %>
66: <%= vtipodeempleo.desplegar%>
67:
68: <% end %>
En el controlador tengo lo siguiente en la opcion update
def update
params[:ucurric][:tipoDeEmpleo] ||= []
@ucurric = Ucurric.find(params[:id])
if @ucurric.update_attributes(params[:ucurric])
flash[:notice] = ‘Ucurric was successfully updated.’
redirect_to :action => ‘show’, :id => @ucurric
else
render :action => ‘edit’
end
end
Espero que alguien me pueda ayudar
Gracias