[英]Render more-like-this view from button
I want to create a button from the search result from Solr (7.5.0) in Blacklight (7.0.1) which on click should render a more-like-this view. 我想从Blacklight(7.0.1)的Solr(7.5.0)的搜索结果中创建一个按钮,单击该按钮应呈现类似此视图的视图。
I have tried to include the button in the catalog_controller and calling the more-like-this view through a helper function. 我试图将按钮包含在catalog_controller中,并通过一个辅助函数来调用类似此视图的视图。 Also tried to direct the routes in the routes.rb. 还尝试在routes.rb中定向路由。
The catalog_controller: catalog_controller:
config.add_index_field 'id', helper_method: :more_like_this
The helper function 辅助功能
def more_like_this
render_document_sidebar_partial
end
catalog_helper_behavior.rb catalog_helper_behavior.rb
def render_document_sidebar_partial(_document = @document)
render partial: 'show_sidebar'
end
Gives me the following error: 给我以下错误:
No route matches {:action=>"show", :controller=>"bookmarks", :id=>nil}, missing required keys: [:id]
How do I pass the id correctly? 如何正确传递ID?
I simply want Blacklight to render the more-like-this view in the right sidebar when the button is pushed. 我只是想让Blacklight在按下按钮时在右侧栏中渲染更类似的视图。
Thanks in advance. 提前致谢。
Two things are problems in what you've posted: 1. the show_sidebar partial expects to have a local called document, so should be called with something like: 您发布的内容有两个问题:1. show_sidebar部分期望有一个本地调用的文档,因此应使用类似以下内容的文件进行调用:
render partial: "show_sidebar", locals: { document: _document }
more_like_this
method is a Rails helper (that is, it returns an html_safe string), not a Blacklight field value helper. Blacklight字段的helper_method配置标识期望使用参数哈希进行调用的方法,该哈希至少具有SolrDocument的:document键和字段名的:field键more_like_this
方法是Rails的帮助器(即,返回html_safe字符串),而不是Blacklight字段值帮助程序。 maybe you are missing the index
action for bookmarks (in your routes and maybe in your controller). 也许您错过了书签的index
操作(在您的路线中,或者在您的控制器中)。
the url you are going to is probably /bookmarks
but you only have something like get "/bookmarks/:id"
in your routes so it's not finding the required :id
parameter. 您要访问的url可能是/bookmarks
但是您的路由中只有get "/bookmarks/:id"
,因此找不到所需的:id
参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.