Text/html Missing Error After Implementing Search in Ruby on Rails

Asked 1 months ago, Updated 1 months ago, 1 views

When I search from the search form, I get an error similar to the picture below.

Enter a description of the image here

 ActionController:: UnknownFormat (SearchsController #index is missing a template for this request format and variant.

request.formats: ["text/html"]
request.variant: [ ]

NOTE! For XHR/Ajax or API requests, this action would normally respond with 204 No Content: an empty white screen. Since you're loading it in a web browser, we assume that you expected to actually render a template, not nothing, so we're showing an error to be extra-clear. If you expect 204 No Content, carry on. That's what you'll get from an XHR or API request. Give it a shot.):

If you look at the terminal, it says that there is no app/views/blog/index.html.erb, but I think both route and view are set.Is there anything else missing?
I would appreciate it if you could teach me.
Thank you for your cooperation.

Below is the code and file of the image post (same content)

 railsg model search name:string


class Search <ApplicationRecord
    as class method in def self.search(search)#self.
        If search# Controller passed parameter != nil, search title column for partial match
          Search.where (['name LIKE?', %#{search}%'])
          Search.all# Show all.


<%=form_tag searches_path, :method=>'get'do%> 
                        <%=submit_tag "Search", :name=>nil%>


  # get "blog/index" = > "searchs #index"


class SearchesController<ApplicationController

    def index
    # Pass the parameters obtained in the View Form to the model

Create model file for search.rb
Install search form in index.html.erb

ruby-on-rails ruby

2022-09-30 11:56

1 Answers

SearchesController#index is missing a template for this request format and variant.

The error is

app/views/blog/index.html.erb missing

Do you need app/views/searches/index.html.erb instead?Or specify that the render method uses the BlogController#index template.

2022-09-30 11:56

If you have any answers or tips

© 2022 OneMinuteCode. All rights reserved.