vendredi 17 septembre 2021

How can show only those user who is not linked with project in rails

I am trying to show only those developers who are not linked with project but it always show one developer who is already linked

ProjectDeveloper is model which have project and developer id User have a column user type which type is enum who contain developer manager and qa

controller

 def index

    @users = User.where(user_type: 'Developer')
    @project_developer = ProjectsDeveloper.where.not(id: @users.ids)
    project_id = params['project_id'].to_i
    @project_id = Project.find(project_id)
 end

html.erb

<% @project_developer.each do |user| %>
   <h3><%=user.developer_id %></h3>

   <%=button_to 'Assign' , projects_developer_index_path({project_id: @project_id.id, developer_id: user.id}),
         method: :post %><br>
<% end %>

Aucun commentaire:

Enregistrer un commentaire