I am trying to display the results of a SHOW action using AJAX.
in the show.js.erb, this renders properly:
$('#someid').html("<p>regular html</p>")
and this renders the name of the selected @category
$('#someid').html("<%= j render @categories %>")
but does not work when trying to render the associated SHOW view (show.html.erb):
$('#someid').html("<%= j render 'show', category: @category %>")
the errors i recieve is as follows:
ActionView::Template::Error (Missing partial categories/_show with {:locale=>[:en], :formats=>[:js, :html, :text, :css, :ics, :csv, :vcf, :vtt, :png, :jpeg, :gif, :bmp, :tiff, :svg, :mpeg, :mp3, :ogg, :m4a, :webm, :mp4, :otf, :ttf, :woff, :woff2, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip, :gzip], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]}. Searched in:
* "/home/ubuntu/environment/project_name/app/views"
* "/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/actiontext-6.0.3/app/views"
* "/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/actionmailbox-6.0.3/app/views"
):
1: $('#someid').html("<%= j render 'show', category: @category %>")
app/views/categories/show.js.erb:1
what can I do to render show.html.erb?
2
Answers
you should change folder
show.html.erb
->_show.html.erb
because it is templale partial to render
Answer on the behalf of OP: