Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/10/2011, 12:54
akela_sil
 
Fecha de Ingreso: octubre-2011
Ubicación: Cádiz
Mensajes: 2
Antigüedad: 13 años, 1 mes
Puntos: 0
Sonrisa Mysql::Error: Unknown column

Hello

I have a problem doing my final project. I try to do 'dynamic select boxes (http://pullmonkey.com/2008/03/30/dynamic-select-boxes-ruby-on-rails/)'.
I have several days with and I can not fix it. I hope I can help.

The error is in the controller. I've mentioned it.

My code:
migracion: create_obras.rb
class CreateObras < ActiveRecord::Migration
def self.up
create_table :admin_obras do |t|
t.string :titulo
……
t.references :admin_coleccion
t.references :admin_artistum
t.references :admin_seccion
t.references :admin_tecnica

t.timestamps
end
end

migracion: create_admin_seccions.rb
class CreateAdminSeccions < ActiveRecord::Migration
def self.up
create_table :admin_seccions do |t|
t.string :nombre

t.timestamps
end
end


migracion: create_admin_tecnicas.rb
class CreateAdminTecnicas < ActiveRecord::Migration
def self.up
create_table :admin_tecnicas do |t|
t.string :nombre
t.references :admin_seccion

t.timestamps
end
end


Is stored in: (… = controller or views …)
app/…/admin/obras
app/…/admin/tecnicas
app/…/admin/seccions

Models:
class Admin::Tecnica “Seccion” # foreign key - admin_seccion


class Admin::Seccion “Obra” # Están en el mismo espacio de nombres
has_many :admin_tecnicas, :class_name => “Tecnica”


class Admin::Obra “Seccion” # foreign key - admin_seccion


Controller: #### THIS IS PROBLEM ####
def update_tecnicas
admin_seccion = Admin::Seccion.find(params[:admin_seccion_id])
admin_tecnicas = admin_seccion.admin_tecnicas #### THIS IS PROBLEM ####

render :update do |page|
#page.replace_html ‘tecnicas’, :partial => ‘/admin/obras/secciones’, :object => @admin_obra
end
end

_secciones.html.erb:

“Seleccione una sección”},
{:onchange => “#{remote_function(:url => {:controller=>”seccions”, :action => “update_tecnicas”},
:with => “‘admin_seccion_id=’ + value”)}”}) %>

He tells me the following error:
Started POST “/admin/seccions/update_tecnicas” for 127.0.0.1 at Sat Oct 01 20:27:28 +0200 2011
Processing by Admin::SeccionsController#update_tecnicas as JS
Parameters: {”authenticity_token”=>”1PXjFEx0a/ngBXIVA7EMp5SVujhffa3AkxU6w130Acc=”, “_”=>”", “admin_seccion_id”=>”1″}
Admin::Seccion Load (0.1ms) SELECT `admin_seccions`.* FROM `admin_seccions` WHERE `admin_seccions`.`id` = 1 LIMIT 1
Admin::Tecnica Load (0.5ms) SELECT `admin_tecnicas`.* FROM `admin_tecnicas` WHERE (`admin_tecnicas`.seccion_id = 1)
Mysql::Error: Unknown column ‘admin_tecnicas.seccion_id’ in ‘where clause’: SELECT `admin_tecnicas`.* FROM `admin_tecnicas` WHERE (`admin_tecnicas`.seccion_id = 1)
Completed 500 Internal Server Error in 24ms

ActiveRecord::StatementInvalid (Mysql::Error: Unknown column ‘admin_tecnicas.seccion_id’ in ‘where clause’: SELECT `admin_tecnicas`.* FROM `admin_tecnicas` WHERE (`admin_tecnicas`.seccion_id = 1)):
app/controllers/admin/seccions_controller.rb:106:in `write’
app/controllers/admin/seccions_controller.rb:106:in `print’
app/controllers/admin/seccions_controller.rb:106:in `update_tecnicas’

Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.9/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.2ms)
Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.9/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (81.0ms)
Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.9/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (86.3ms)

====================
THIS:
Mysql::Error: Unknown column ‘admin_tecnicas.seccion_id’ in ‘where clause’:
SELECT `admin_tecnicas`.* FROM `admin_tecnicas` WHERE (`admin_tecnicas`.seccion_id = 1))

SHOULD BE, but do not know how:

SELECT `admin_tecnicas`.* FROM `admin_tecnicas` WHERE (`admin_tecnicas`.admin_seccion_id = 1))
===========================



I await your favorable support.
Thank you

Regards