jeudi 25 février 2016

When ActionView::MissingTemplate in Rails happens?

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!

Aucun commentaire:

Enregistrer un commentaire