link_to在数据内容中为bootstrap 4 popover

时间:2017-10-19 18:54:42

标签: ruby-on-rails href bootstrap-4 popover link-to

我想在我的popover的数据内容中添加一个链接。不使用<%link_to'将其保存到您的活动',usersavedevents_path,method :: post%>因为它不起作用,它会进入UI。

视图

<div class="col-1" tabindex="0" data-container="body" data-trigger="focus" data-toggle="popover" data-placement="top" title="Save" data-content="Not sure if you're going? <a rel='nofollow' data-method='get' href='/usersavedevents/new?user_id=1'>Save it to your events</a> and we'll remind you closer to the start date.">
                <%= image_tag "bookmark.png", height: '25px' %>
              </div>
<script>

              $(function () {
                $('[data-toggle="popover"]').popover(
                  {html : true
                  })
              })</script>
              <script>
              $('.popover-dismiss').popover({
                trigger: 'focus'
              })</script>

控制器(我现在有root_path来测试它,看看我是否采取行动)

class UserSavedEventsController < ApplicationController
def new
    redirect_to root_path
end

def create
    redirect_to root_path   
end
end

路由

  resources :usersavedevents

继续收到此错误:

Routing Error
uninitialized constant UsersavedeventsController

1 个答案:

答案 0 :(得分:1)

我认为你的命名是错误的:

<强>的routes.rb

resources :user_saved_events

因此路径为user_saved_events_path

确保您的文件名遵循Rails约定:

user_saved_events_controller.rb

这是rails naming conventions

上的一些文档