[ad_1]
I am using the “similar_text” gem.
I have a model, “Candidate Committee” that has multiple “transactions.” The candidate committee also is owned by a “Person”. I am trying to detect if any of the names of the transaction match the name of the Person.
Here is my method in the “Candidate Committee” model:
def self_fund
a = Array.new
transactions.where(transaction_type: "RCPT").each do |transaction|
if transaction.full_name}.similar(person.full_name) > 90
a << transaction
end
end
a
end
When I run this via console, it works perfectly.
When I run it via the views page with the following code…
<% if @candidate_committee.self_fund.count > 0 %>
<% @candidate_committee.self_fund.each do |transaction| %>
<%= transaction.amount %>
<%end%>
<%end%>
…I get:
undefined method `similar' for "John Smith":String
I can’t figure out what might be going wrong here, any advice would be appreciated! Part of me thinks that the app itself isn’t utilizing the gem correctly, while the console is, but that’s not an issue I’ve encountered before nor am I sure that’s really possible or not.
[ad_2]