responders

    8熱度

    2回答

    class Api::StoresController < ApplicationController respond_to :json def index @stores = Store.all(:include => :products) respond_with @stores end end 只返回商店沒有自己的產品,一樣 Stor

    8熱度

    1回答

    我正在尋找一個寶石或解決方案來在控制器響應中生成圖像。 這將是很好,如果有可能的控制器,這樣做: respond_to :html, :png def show ... respond_to do |format| format.html format.png { ??? } # some html to png converter end

    1熱度

    2回答

    我想弄清楚如何從一個自定義響應者設置佈局。我想使用request.xhr?將渲染布局設置爲'ajax'。有誰知道如何做到這一點? 我用Rails 3,我有這樣的應答: module AjaxLayoutResponder def to_html if request.xhr? # do something here to change layout...

    3熱度

    2回答

    在控制器,我想respond_with更換if..render..else..render: # Current implementation (unwanted) def create @product = Product.create(product_params) if @product.errors.empty? render json: @product

    0熱度

    1回答

    我使用的軌道respond_with發送JSON響應到客戶端關聯,而我試圖找出如何連同where子句中我聯想使用 includes選項 respond_with 這裏是我的模型: class User < ActiveRecord::Base has_many :ratings has_many :movies, through: :ratings end class R

    1熱度

    1回答

    我正試圖使用​​裸露的骨骼軌道控制器,並在同一時間有更細粒度的控制。如果我在:新行動,我回應我的新@實例,我得到一個狀態代碼200並呈現:新模板。在展會上,同樣的事情,不同的模板。到現在爲止還挺好。但是,在創作上,我遇到了意想不到的事情。如果新記錄成功並且我打電話給respond_with,我將被重定向到顯示(狀態碼302),這是正確的。但是,如果由於記錄無效而無法創建新記錄,則默認的respon

    1熱度

    2回答

    我運行軌道3.2.1和使用Rails的反應寶石可用3個應答以及閃光燈響應:https://github.com/plataformatec/responders 對於我的一些控制器動作我總是希望重定向回以前的網址,但如果在創建或不是對象顯示一個提示信息,它看起來是這樣的: class MyController < ActionController::Base responders :fl

    0熱度

    1回答

    我正在使用responders gem,並且我想在窗體無效時顯示驗證錯誤。在我的控制,我創建了interpolation_action def interpolation_options { resource_errors: @project_user.errors.full_messages.join(', ') } end 和我reponders翻譯文件中有一個正確的密鑰: p