Best in place building exotic method after creation

廉价感情. 提交于 2019-12-12 00:06:03

问题


I am attempting to use the best_in_place gem to allow inline editing to my data-tables. I have successfully added it to another, but adding it now creates an exotic path variable campaign_category_metro_bid_path when I add the final column of the table implementing best_in_place for some reason.

Why is the error occurring?

update_bidding.html.erb:

<tbody>
  <% CampaignCategoryMetroBid.where(campaign_id: @campaign.id).each do |biddetail| %>
        <tr>
            <td><%= biddetail.id %></td>
            <td><%= biddetail.campaign_id %></td>
            <td><%= biddetail.category_id %></td>
            <td><%= biddetail.metro_id %></td>
            <td><%= biddetail.average_bid_price %></td>
            <td><%= biddetail.average_placement %></td>
            <td><%= biddetail.number_times_pulled %></td>
            <td><%= biddetail.clicks %></td>
            <td><%= biddetail.shares %></td>
            <td><%= biddetail.get_there %></td>
            <td><%= biddetail.user_saves %></td>
            <td><%= best_in_place biddetail, :set_max_bid %></td>
        </tr>
    <% end %>
</tbody>

campaigns controller action:

def update_bidding
    @campaign = Campaign.find_by_id(params[:id])
end

Error:

undefined method `campaign_category_metro_bid_path' for #<#<Class:0xa01f610>:0x601b360>
Extracted source (around line #52):
49
50
51
52
53
54
55

                    <td><%= biddetail.shares %></td>
                    <td><%= biddetail.get_there %></td>
                    <td><%= biddetail.user_saves %></td>
                    <td><%= best_in_place biddetail, :set_max_bid %></td>
                </tr>
            <% end %>
       </tbody>

回答1:


Turns out I simply forgot to place the new controller into the routes so paths can be accessed:

resources :campaign_category_metro_bids, only: [:update, :update_bidding]

All works now



来源:https://stackoverflow.com/questions/30090219/best-in-place-building-exotic-method-after-creation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!