vendredi 2 décembre 2016

Fields for not working with nested attributes rails

For some reason fields_for is not showing my nested attribute text boxes. I have followed the guide on how to get it to work but still zero luck. Any help would be greatly appreciated.

*The strange part of this is I had working using Oracle as a db then I switched to Sqlserver and now it doesn't work.

Here is my Entry modle

class Entry < ActiveRecord::Base
  include WorkorderTranslator
  belongs_to :release
  belongs_to :session
  belongs_to :sheet

  has_many :stm_entries, :dependent => :destroy

  attr_protected :id
  accepts_nested_attributes_for :stm_entries

class StmEntry < ActiveRecord::Base


  self.primary_key = 'id'

  belongs_to :entry

  attr_protected :id

Here is my view

=f.simple_fields_for :stm_entries, stm do |ff|
  %td.b.trace-table{:style => 'padding-top:3px;'}
    = ff.input :date, :as => :string, :readonly => true, :input_html => {:style => 'width:90%;', :value => (ff.object.date.nil? ? Date.today.strftime("%m/%d/%Y") : ff.object.date.strftime("%m/%d/%Y")), :placeholder => 'Date', :class => 'floatlabel'}, :label => false
  %td.b.trace-table{:style => 'padding-top:3px;'}
    = ff.input :user, :readonly => true, :input_html => {:style => 'width:90%;', :placeholder => 'User ID', :class => 'floatlabel'}, :label => false
  %td.b.trace-table{:style => 'padding-top:3px;'}
    = ff.input :splices, :label => false, :input_html => {:style => 'width:90%;', :placeholder => 'Splices', :class => 'floatlabel'}

Aucun commentaire:

Enregistrer un commentaire