?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 %>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Coze智能助手搭建过程中的问题请教
  • ¥15 12864只亮屏 不显示汉字
  • ¥20 三极管1000倍放大电路
  • ¥15 vscode报错如何解决
  • ¥15 前端vue CryptoJS Aes CBC加密后端java解密
  • ¥15 python随机森林对两个excel表格读取,shap报错
  • ¥15 基于STM32心率血氧监测(OLED显示)相关代码运行成功后烧录成功OLED显示屏不显示的原因是什么
  • ¥100 X轴为分离变量(因子变量),如何控制X轴每个分类变量的长度。
  • ¥30 求给定范围的全体素数p的(p-2)/p的连乘积值
  • ¥15 VFP如何使用阿里TTS实现文字转语音?