I am trying drag and drop in RoR for the first time.
What I want to achieve, is a list of slots, and a list of entries. You
should be able to drag an entry onto a slot and slot.entry_id will
update to match the dragged entry.entry_id.
I’ve spent a lot of time looking in textbooks and online, but cannot
get the drop_receiving_element to fire. When I release an item over
the slot, the item simply reverts. If someone could look through the
code I’ve pasted and gave a hint I would appreciate it.
- Here is the VIEW for the page:
<% f.fields_for :slots do |builder| %>
<% element_to_drop_id = “slot” %>
<% end %>
- Here is the partial entry_list_for_drag
<% @entries.each do |entry| -%>
<% element_to_drag_id = “entry_#{entry.id}” %>
<%= entry.title %> <%= entry.body %>
- Entries and slots exist on pages. In the page controller I’m
starting to set up the below but I can’t even get this to trigger
def set_entry
@slot = Slot.find(params[:slot_id])
entry_id = params[:entry]
@slot.entry_id = entry_id
end