class Api::StoresController < ApplicationController
respond_to :json
def index
@stores = Store.all(:include => :products)
respond_with @stores
end
end
只返回商店沒有自己的產品,一樣 Stor
我正在尋找一個寶石或解決方案來在控制器響應中生成圖像。 這將是很好,如果有可能的控制器,這樣做: respond_to :html, :png
def show
...
respond_to do |format|
format.html
format.png { ??? } # some html to png converter
end
我想弄清楚如何從一個自定義響應者設置佈局。我想使用request.xhr?將渲染布局設置爲'ajax'。有誰知道如何做到這一點? 我用Rails 3,我有這樣的應答: module AjaxLayoutResponder
def to_html
if request.xhr?
# do something here to change layout...
我使用的軌道respond_with發送JSON響應到客戶端關聯,而我試圖找出如何連同where子句中我聯想使用 includes選項 respond_with 這裏是我的模型: class User < ActiveRecord::Base
has_many :ratings
has_many :movies, through: :ratings
end
class R