Reputation: 23
The problem
Screenshot of Stackoverflow tags field
Similar to the tags field on Stackoverflow when you add a question, I would like to add an input field for users to add comma-separated tags when they create new projects.
projects > project_tags (join table) < tags
If a tag does not exist, it would be added to the tags
table, then to project_tags
to link the project itself.
If the tag already exists, it would simply be linked by adding a connection in project_tags
.
Code
# new.html.erb
<%= simple_form_for @project do |f| %>
<%= f.input :name, label: "Project name" %>
...
<%= f.simple_fields_for :tags do |t| %>
<%= t.input :tags %>
<% end %>
...
<% end %>
Upvotes: 0
Views: 170