Using rails 4, when I want to render a form (with simple_form) from an object Document::Document I have this error: undefined method document_type_id for #<Document::Document:0x007fada4a50240>
Here a part of my model:
class Document::Document < ActiveRecord::Base
...
belongs_to :document_type, -> {include(:translations)}, :class_name => 'Document::Type'
...
end
The method new of my controller:
def new
@document = Document::Document.new
end
And a part of the form with simple_form:
=f.association :document_type, prompt: t('document.documents.form.choose_document_type'), collection: Document::Type.includes(:translations)
The error:
undefined method `document_type_id' for #<Document::Document:0x007fada4a50240>
Extracted source (around line #14):
11 .row
12 =f.input :language, collection: languages_list, prompt: t("document.documents.form.choose_language"), label_html: tooltip(t('document.documents.forms.tooltips.language')), wrapper_html: {class: 'columns large-4'}, input_html: {class: 's2'}
13 =f.input :study_level, prompt: t('document.documents.form.choose_study_level'), label_html: tooltip(t('document.documents.forms.tooltips.study_level')), wrapper_html: {class: 'columns large-4'}, input_html: {class: 's2'}
14 =f.association :document_type, prompt: t('document.documents.form.choose_document_type'), collection: Document::Type.includes(:translations), label_html: tooltip(t('document.documents.forms.tooltips.type')), wrapper_html: {class: 'columns large-4'}, input_html: {class: 's2'}
15 -#=f.association :domains, collection: Domain.includes(:translations).order('name ASC'), label_html: tooltip(t('document.documents.forms.tooltips.domains')), input_html: {class: 's2'}
16 .form-actions
17 =f.button :submit, t('document.documents.form.submit')
Why this error ?
I upgraded from rails 3.2. Before everything works great.
In rails 3.2 I had added that:
attr_accessible :document_type_id, ...
Maybe the error is coming from there