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|".

查看全部
weixin_33738982
?Briella
2015/12/21 15:18
  • ruby-on-rails
  • ajax
  • 点赞
  • 收藏
  • 回答
    私信

1个回复