모델에 속하지 않는 select 양식을 사용하여 양식을 제출해야합니다. 다른 작업을 한 후 작업을 저장하기위한 I이 값이 필요합니다,하지만 난 오류가 나타납니다모델에없는 필드가있는 레일 양식을 제출하십시오.
undefined method `tecnico' for #<Interventi:0x9802cf8>
이 내 양식의 일부입니다
<%= form_for :interventi, url: welcome_nuovointerventosalva_path do |f| %>
<div class="row">
<div class="col-md-2">
<%= f.label :data, 'Data creazione' %>
<div class="form-group input-group">
<span class="input-group-addon"> <i class="fa fa-calendar"></i> </span>
<%= f.text_field :data, :class => "date-picker form-control input-mini", readonly: true, :value => Time.now.strftime("%Y/%m/%d") %>
<!--<span class="help-block">formato YYY-MM-DD</span> -->
</div>
</div>
....................................
....................................
<div class="col-md-3">
<%= f.label 'Tecnico' %>
<div class="form-group input-group">
<%= f.select :tecnico, options_for_select(@tecnici.collect{ |tec| [tec.nome, tec.id] }), {}, class: 'form-control search-select' %>
</div>
</div>
이 컨트롤러
def nuovointervento
@titolo = "Nuovo Intervento"
@interventi = Interventi.new
@clienti = Clienti.all.order(:nome)
@categorie = Categorie.all
@tecnici = Utenti.where(operatore: '1').order(:nome)
입니다 끝
끝
예, 필드 'TECNICO가'Interventi 모델하지만, 사후 조치에 속하지 않는, 내가 tecnico_id에 저장 다른 레코드에 대한이 값을 필요로하고 'intervento'작성 후 저장 ID (조인 테이블)
어떻게 해결할 수 있습니까?
탱크!
[양식 필드가 레일 DB 모델의 일부가 아님] 가능한 복제본 (http://stackoverflow.com/questions/11060220/form-field-not-part-of-rails-db-model) – MageeWorld
그림의 조인 테이블이며이 문제는 accepts_nested_attributes로 가야합니다. –