Help with issue inserting associated field

21 views
Skip to first unread message

Tomás Rinke

unread,
Mar 11, 2014, 9:12:29 AM3/11/14
to net...@googlegroups.com
Hello, this is my first project with ror and netzke. I have two models Person and Interaction (one person can have many interactions) for a social worker office. 

i managed to show person last name in Interaction grid but when i click apply the id doesn´t persist, eventhough i see it noticed the change, but it cannot relate it to the person_id. I thought it would be kinda automatic. perhaps i´m breaking some convention. 

log:
Processing by NetzkeController#direct as HTML
  Parameters: {"path"=>"person_tab_panel__interactions", "endpoint"=>"postData", "data"=>[{"args"=>{"updated_records"=>"[{\"person__apellido\":2,\"id\":1}]", "base_params"=>"{}"}, "configs"=>[{"id"=>"person_tab_panel"}, {"id"=>"person_tab_panel__interactions"}]}], "tid"=>5, "authenticity_token"=>"eO8W5UpWgbbORsfzFycXgG85OxSiZqFJcOZgZkkrZU4=", "netzke"=>{"path"=>"person_tab_panel__interactions", "endpoint"=>"postData", "data"=>[{"args"=>{"updated_records"=>"[{\"person__apellido\":2,\"id\":1}]", "base_params"=>"{}"}, "configs"=>[{"id"=>"person_tab_panel"}, {"id"=>"person_tab_panel__interactions"}]}], "tid"=>5}}
  Interaction Load (1.5ms)  SELECT "interactions".* FROM "interactions" WHERE "interactions"."id" = 1 LIMIT 1
   (0.1ms)  begin transaction
   (0.1ms)  commit transaction


Components:
class Interactions < Netzke::Basepack::Grid
  def configure(c)
    super
    c.model = "Interaction"
    c.persistence = true
    c.columns = [
        { id:  :person__apellido, name: :person__apellido, header: 'Persona'},
        :voluntario
    ]
  end
end


Models: 
class Person < ActiveRecord::Base
  has_many :interactions
  attr_accessible :apellido, :documentoar, :documentoextra, :domicilio, :fecha_nac, :nombre, :sector, :telefono1, :telefono2
  validates_presence_of :documentoar
  def name
    "#{apellido}, #{nombre}"
  end
end

class Interaction < ActiveRecord::Base
   belongs_to :person
   attr_accessible :fecha_seguimiento, :propuesta, :situacion, :tipo, :voluntario

end

i´ve been playing a lot with this and could not figure it out...

my setup is: 
ruby 1.9.3p545
Rails 3.2.8.rc1
netzke-basepack (0.8.4)
netzke-core (0.8.4)

any clues?

thanks in advance

Tomás Rinke

unread,
Mar 19, 2014, 1:27:22 PM3/19/14
to net...@googlegroups.com
re did the models, and put only belongs_to, and worked fine. 
Thanks!
Reply all
Reply to author
Forward
0 new messages