在我的 Rails 应用程序中,我创建了一个控制器来从数据库中获取数据,其中还包括模型中的参数,如下所示。
问题是views文件夹中没有html页面。我需要运行控制器吗???我想要输出我的 json 格式.. html 页面是如何创建的,我在哪里可以看到我的 json 格式的数据...
# shoppingDemo.rb (controller)
class ShoppingDemo < ApplicationController
  def index
    @lists=products.all;
    respond_to do |format|
      format.html
      format.json { render json: @lists}
    end
  end
  def show
    @products = products.find(params[:prod_id])
    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @products }
    end
  end
end
# products(model)
class products < Activerecord::Base
  attr_accessible :model_name, :brand_name, :price, :discount, :qty_available
end
创建 html 页面或以 json 格式从数据库中查看我的数据的下一步是什么。