外部SQLデータベースにアクセスしています。関連するフィールドを正しくアドレス指定できません
:そのためのRBのファイルは、私が私にここActiveRecord::ConfigurationError in Searches#show
Showing C:/Users/cmendla/RubymineProjects/product_development/app/views/searches/show.html.erb where line #18 raised:
Association named 'users' was not found on Opportunity; perhaps you misspelled it?
Rails.root: C:/Users/cmendla/RubymineProjects/product_development
Application Trace | Framework Trace | Full Trace
app/views/searches/show.html.erb:18:in `_app_views_searches_show_html_erb__590262190_43507272'
の誤差を与えること
@opportunities = @opportunities.joins(:users).where("users.name like ?", "%#{account_manager}%")
に参加し、選択しようとしています
class CrmTable < ActiveRecord::Base
self.abstract_class = true
def self.table_name_prefix
'dbo_'
end
establish_connection "crm_tables"
end
class Address < CrmTable
self.table_name = "Address"
end
class Opportunity < CrmTable
self.table_name = "Opportunity"
# belongs_to :Person, foreign_key: :primarypersonid
belongs_to :user
end
class CrmUser < CrmTable
self.table_name = "Users"
has_many :opportunities
end
は、ログデータです
ActionView::Template::Error (Association named 'users' was not found on Opportunity; perhaps you misspelled it?):
15:
16: <% if 5 == 5 then %>
17: <hr>
18: <% @opportunities.each do |opportunity| %>
19: <hr>
20:
21: <h1>New item</h1>
app/views/searches/show.html.erb:18:in `_app_views_searches_show_html_erb__590262190_43507272'
注 1 - 私はadauth認証のためのユーザーと呼ばれるテーブルも持っています。それが問題の原因になるかどうかはわかりません。 2 - レールアプリからテーブルが
'database.yml'を投稿してください。 CrmTableはクラスではなくモジュールでなければなりません。ネストされたすべてのモデルが子孫ではなく含まれています。 – Almaron