0

how resolve this error:

SQLite3::SQLException: no such column: functionalities.profile_id: SELECT "functionalities".* FROM "functionalities" WHERE "functionalities"."profile_id" = 1

This is my _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

I think that I need make a join, because the error is in when I'm on else.

4

1 に答える 1