wie diesen Fehler beheben:Fehler bei collection_check_boxes
SQLite3 :: SQLException: keine solche Spalte: functionalities.profile_id: SELECT "Funktionalitäten" * FROM "Funktionalitäten" WHERE "Funktionen" "profile_id" = 1..
Das ist mein _form.html.erb
<h3>Add functionalities</h3>
<% if current_user.admin? %>
<%= f.collection_check_boxes :functionality_ids, Functionality.all, :id, :description %>
<% else %>
<%= f.collection_check_boxes :functionality_ids, Functionality.where(profile_id: current_user.profile.id), :id, :description %>
<% end %>
Profile.rb
has_many :users
has_many :profile_functionalities
has_many :functionalities, through: :profile_functionalities
belongs_to :manager
belongs_to :agent
Functionality.rb
# Nothing here for now
ProfileFunctionality.rb
belongs_to :profile
belongs_to :functionality
Ich denke, dass ich machen müssen einen Join, da der Fehler in ist, wenn ich auf sonst.
warum nicht nur 'current_user.profile.functionalities' anstelle von' Functionality.where (profile_id: current_user.profile.id) '? Da Sie nichts für das 'Functionality'-Modell gepostet haben, ist es schwierig, diese Beziehung zu bestimmen, aber ich würde annehmen, dass es keine' profile_id' hat, da dies Ihre Join-Tabelle 'ProfileFunctionality' ist. – engineersmnky