Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActionController::UnknownFormat when I use respond_to + respond_with (Rails 4)

I can't understand what's happening, when I ask for index action I receive ActionController::UnknownFormat, even existing a index.js file inside views/products folder. Anyone can help me to figure out what I'm missing out? I'm using Rails 4 and Ruby 2.0.0-p247.

class ProductsController < ApplicationController
  respond_to :js
  def index
    @products = Product.published.newest.page(params[:page])
    respond_with @products
  end

end
like image 886
Vitorino Avatar asked Dec 18 '13 20:12

Vitorino


1 Answers

You should specify the format on the petition, i.e:

get :show, :user_id => user_id, :format => :json

like image 79
marco_alacot Avatar answered Nov 08 '22 20:11

marco_alacot