ruby on rails - Nested Model Form. Belongs_to class not displaying -
I have a topic model and a text model I have implemented the nested model form.
After creating the topic, I took it to a page where it shows the guessed lesson. However, I failed to see the lessons.
I believe the lesson data is not saved properly when I have given lesson for example. FID_by_accact_id ('1'), I get 'zero' in return.
I am trying to explain how polymorphism works on the railway and if someone tells me where I am getting wrong or guiding me, it has to be made.
topic model
attr_accessible: subjectcode,: lessons_attributes is_maya: lessons, dependent => : Delete accepts_nested_attributes_for: lessons ,: reject_if = & gt; Lambda {| One | A [: content] .blank? } ,: Allow_destroy = & gt; Topic text model
attr_accessible: lessonName, subject: subject_id related to: topic content controller < / P> > > theme> Gt; "Theme created successfully." And render: action = & gt; End of 'new' end form
& lt;% = form_for @subject do | F | & Gt%; & Lt;% = f.error_messages% & gt; & Lt; P & gt; & Lt;% = f.label: subjectCode% & gt; & Lt; Br / & gt; & Lt;% = f.text_field: subjectCode% & gt; & Lt; / P & gt; & Lt;% = f.fields_for: Lesson | Builder | & Gt%; & Lt; P & gt; & Lt;% = builder.label: Subname% & gt; & Lt; Br / & gt; & Lt;% = builder.text_area: Subtitle, Rows = & gt; 3% & gt; & Lt; / P & gt; & Lt;% end% & gt; & Lt; P & gt; & Lt;% = f.submit "Submit"%> & Lt; / P & gt; & Lt;% end% & gt; Route processing: topics are resources: text end
your reject_if lambda will always reject text attributes because the text does not contain the content attribute, so you essentially zero. Blanc? are evaluating true
Maybe you want to see if the name of the text is empty or not? All : reject_f = & gt; Lambda {| One | A [: lessonName] .blank? }
Comments
Post a Comment