I came across a sporadic error, allegedly because Rails sometimes could not find a partial one. However, due to the fact that the error appeared only in some cases, I suspected and then found another error underlying it.
My question is: does anyone know of a reliable way to determine the underlying error in this case?
The obvious mistake:
Rails threw this error when responding to a JSON view request new.json.erb
:
ActionView::Template::Error (Missing partial insightly_contacts/search_result with {:locale=>[:en], :formats=>[:json], :handlers=>[:erb, :builder, :coffee]}. Searched in:
* "/path/to/project/app/views"
This was strange for two reasons:
- A partial question is present, and it joyfully does most of the time.
The partial question does not apply to the format :json
; although it new.json.erb
is a JSON template, obviously it makes it similar partial (specifying the format :html
):
form_object.possible_insightly_contacts.map { |insightly_contact|
{
id: insightly_contact.id,
html: render(partial: 'insightly_contacts/search_result', locals: { insightly_contact: insightly_contact }, formats: :html)
}
}.to_json.html_safe
Notes:
possible_insightly_contacts
returns ActiveRelation.
, form_object
. , possible_insightly_contacts
; 'x' , 'z' ( , "x" "z" / !)
form_object
, possible_insightly_contacts
, - - possible_insightly_contacts
- .
:
( : , , " " )
, - , insightly_contact
. , : , - , .
:
? // , , , .
HTML, , .
, , , .
- / ?
?