I want to display only those with a specific column in the list, so I first google the description to take that record in the SQL statement. Then
SELECT *FROM table name WHERE column name IS NULL;
Discovered! After checking, it seems that the record targeted by this description has been acquired.
In this case, the tasks are lined up in a list. How can I display only tasks for which the Point column of the tasks table is empty? First, go to check the index
 <% if user_signed_in? %>
    <%= @tasks.each do |task| %>
       <%= link_to edit_task_path(task.id) do %>
           <div class="task" >
           <span class='task-btn'><%= task.content %></span>
           </div>
       <% end%>   
     <% end %>
 <% end %>  
This is a description that is lined up in a list. This @tasks is defined by the controller, so go to see the controller
def index
      if user_signed_in?
      @tasks = Task.all
      end
  end
I think it is necessary to change the description to be assigned in this @task, and I worry about 2 hours. Conclusion
def index 
      if user_signed_in? 
      @tasks = current_user.tasks.where(point: nil)
      end
  end
I was able to display a record with an empty Point on the screen with the description of. I was taught how to specify a condition from the tasks table in user.tasks.where (condition) and display it in a different case before, so I was able to solve it by getting a hint from it.
Recommended Posts