我在我的应用程序中使用了 textacular,但我的功能正在爆炸。以下代码:
Background:
Given the following "project" records:
| name |
| Project 1 |
| Project 2 |
And I am on "the projects page"
Scenario: Find projects by content
When I search for "Project 1"
Then I should see the project called "Project 1" in the project list
用这条消息炸毁:
When I search for "Project 1" # features/step_definitions/search_steps.rb:11
PG::Error: ERROR: function similarity(character varying, unknown) does not exist
LINE 1: SELECT "projects".*, similarity("projects"."name", 'Project\...
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
: SELECT "projects".*, similarity("projects"."name", 'Project\ 1') AS "rank79552331411843676" FROM "projects" WHERE (("projects"."name" % 'Project\ 1')) ORDER BY "rank79552331411843676" DESC (ActionView::Template::Error)
我在 Postgres 中安装了 Trigram 模块,因为我正在使用模糊搜索,并且在开发中一切正常。我不完全理解此错误消息的含义。这是我的更多代码:
# search_steps.rb
When(/^I search for "(.*?)"$/) do |query|
fill_in 'query', with: query
click_button 'Search'
end
# GET /projects
def index
@projects = Project.search(params[:query])
end
# project.rb
def self.search(query)
return all unless query.present?
fuzzy_search(query)
end
有没有人遇到过并解决过这个问题?