?Briella 2015-12-21 15:18 采纳率: 0%
浏览 18

response_to UnknownFormat

show.html.erb file:

<%= button_to "1w", installation_path, params: { type: "graph", time: "week" },  :class => "button", :method => :get %>

show.js.erb file:

$("#main-graph").html("<%= escape_javascript(render :partial => 'graphs/consumptionsChart',  :locals => {installation_id: @id_ins}) %>");

controller:

  def show
    if params[:type] == "graph"
      @id_ins = "80"
      respond_to do |format|
        format.js
      end
    end 
  end

When I click in a button "1w" I receive the error "ActionController::UnknownFormat" in the line of "respond_to do |format|".

  • 写回答

1条回答 默认 最新

  • weixin_33701294 2015-12-22 11:56
    关注

    Try this

    <%= button_to "1w", installation_path(:format => "js"), params: { type: "graph", time: "week" },  :class => "button", :method => :get %>
    
    评论

报告相同问题?