ruby - Nested Rails Objects Forms and haml -


I've got a rail model class which comes under the other models in the application. Now I have to submit an edit form.

Below is a sample class that I want to receive:

 I want to update the record of related items respectively ...  class booking & lt; ActiveRecord :: Base `is_to: user belongs_to: section belongs_to: invoice ,: class_name = & gt; "Department" end   

Even after this I have tried to render the edited form. I am not familiar with the haml syntax and there are very few documents that cover this matter.

  = form_for: booking, url = & gt; Booking_path (@ booking),: html = & gt; {: Method = & gt; : Put} do | Form | % Ul - @ booking.rursers.free_message.each me. Msg | % Li = msg = Labels: Bookings:: Status = form.text_field: Status --form.fields_for: User | User_form | / User_form.label: user ,: fullname = user_form.text_field: fullname = form.submit "update this booking"   

Thank you for your reply ..

haml indentation is not used at all, real use of rail helpers etc. When you indent a line through 2 places, then it is understood that the within the section of your indented section was not included which was non-indented. This is as follows:

 % ul # hello% li My list item   

It's done:

  & Lt; Ul id = 'hello' & gt; & Lt; Li & gt; My list item & lt; / Li & gt; & Lt; / Ul & gt;   

This also applies to the do block if you have a rail assistant, then you have to indent the block of assistant, as you would on the remaining markup Depends. The attack will automatically append termination , when the endonement will end. You should change your markup to look like this, I've added some comments for clarity:

  = form_for: booking,: url = & gt; Booking_path (@ booking),: html = & gt; {: Method = & gt; : Put} do | Form | % Ul - @ booking.rursers.free_message.each me. Msg | - # It looks good yet ... right indent inside this `two 'block.% Li = msg - # I think we are no longer in error message block, but you were still indenting here . I have removed the indenture to indicate that we are no longer in that block - # this will work fine, but are not you using `form.label: status` here? = Label: Booking: Status = form.text_field: status - # I changed it to use `= form.` Because I believe the second version (-) has been deprecated = form.fields_for: User do | User_form | - # You did not indent this correctly, you have to indent it properly to be part of the dock block. Fixed = User_form.label: fullname = user_form.text_field: fullname - #This is not part of call `fields_for`, so I have removed the indenture to indicate that it is part of the external section. Hope it was useful :) may feel a bit awkward in the first condition but I have found that it greatly helps in the pace of development and it is very easy for me to read and write about me for a week But it grew up on me and now I will never see behind 



Comments