1

When does ActionView::MissingTemplate usually happens in Rails? I have an API which it can't possibly return above error, but when mobile triggered the routes. It happens two time the ActionView::MissingTemplate error.

Here is a sample code in controller on my API:

def search
  @search_text = params[:search_text]
  unless @search_text.blank?
    @my_models = MyModel.find_all_by_age(@search_text)
  else
    @my_models = []
  end

  render 'api/v4/my_models/show', status: 200, formats: :json
end

On my Routes:

namespace :api, defaults: {format: 'json'} do
  namespace :v4 do
    resource :my_models, only: [:search] do
        get :search
      end
  end
end

I am puzzled when does ActionView::MissingTemplate happens? Could someone point me when does this error happens? Is this mobile missed something in the URL to make this error happen? How?

Thanks!

2 Answers 2

0

You can have ActionView::MissingTemplate error when you include %dd and %ff in url parameter. Because the following are special characters in ASCII Encodings . %dd is for special character Ý

For example,

localhost:3000/api/users?search=%dd

localhost:3000/api/users?search=%ff

Any case on parameter which includes %ff and %dd. Like d%dd.

2
0

ActionView will look for templates/partials in the current controllers view folder. However, if you have changed the view path in the controller, then you will be able prepend and append different view paths for it.

In your search method, you have render 'api/v4/my_models/show', make sure you have the correct template in the listed working directory.

2
  • Yes. I have template views/api/v4/my_models/show.html.rabl.
    – user5928022
    Feb 26, 2016 at 4:07
  • 1
    @inarwarks can you post the complete error message as well?
    – Jefferson
    Feb 26, 2016 at 4:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.