Answer the question
In order to leave comments, you need to log in
How to bind User and Task models in RoR todo list app?
I am writing a To do list application (project management) in Ruby on Rails. There are three models:
1.
Project
2. Task title:string descr:text project:references
3. User name:string email:string
it was possible to assign a user (user) to it, one task per user, when the task is deleted, the user becomes free again. I will also be very grateful if you immediately tell me how to display this correctly in the view
Answer the question
In order to leave comments, you need to log in
How to add input(select) to the form of the view, with the choice of the name User(name), so that the user id from the "users" table would be added to the "tasks" table in the "user_id" field.
app/views/tasks/_form
<%= form_for([@project, @task]) do |form| %>
<p>
<h5>Название:</h5>
<%= form.text_field(:title, {:class => 'form-control'}) %>
</p>
<p>
<h5>Описание:</h5>
<%= form.text_area(:description, {:class => 'form-control'}) %>
</p>
<p>
<span><b>Статус задачи: <b></span>
<%= form.select(:status, Task::STATUSTASKS, {:class => 'span2'}) %>
</p>
<%= form.submit("Сохранить", {:class => 'btn btn-outline-success'}) %>
<%= link_to("Назад", project_path(@project), {:class => 'btn btn-outline-secondary'}) %>
<% end %>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question