When I'm going to index action it outputs whole data from my model, as I understood when I'm going to show action it supposed to output only object depends on id param, but in my case it output the same data as it were in index action.
My active model serializer:
class CategorySerializer < ApplicationSerializer
attributes :id, :name, :alias, :parent_category_id, :position, :menu, :status
has_many :subcategories
has_many :products
end
Controller:
module API
module Store
class CategoriesController < ApplicationController
def index
@categories = Category.all
if params[:name]
@categories = Category.find_by(name: params[:name])
end
puts @categories
render json: @categories
end
def show
@category = Category.find(params[:id])
render json: @category
end
end
end
end