Skip to content

Commit f496b1d

Browse files
committed
Merge branch 'binary-ids-in-sortable-tables' of https://github.com/tsutsu/ex_admin
2 parents cc0e2dc + 2159fa7 commit f496b1d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

web/controllers/admin_association_controller.ex

+5-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ defmodule ExAdmin.AdminAssociationController do
4848

4949
selected_ids
5050
|> Enum.each(fn(assoc_id) ->
51-
assoc_id = String.to_integer(assoc_id)
51+
assoc_id = if String.match?(assoc_id, ~r/^\d+$/) do
52+
String.to_integer(assoc_id)
53+
else
54+
assoc_id
55+
end
5256
Ecto.build_assoc(resource, through_assoc, %{resource_key => resource_id, assoc_key => assoc_id})
5357
|> repo().insert!
5458
end)

web/static/vendor/active_admin/lib/sortable_associations.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $(document).ready(function() {
1818
//$("#progress").show();
1919
var positions = [];
2020
$.each($('table.sortable tbody tr'), function(position, obj){
21-
var reg = /(\w+_?)+_(\d+)/;
21+
var reg = /^(\w+_?)_([-0-9a-f]+)$/i;
2222
var parts = reg.exec($(obj).prop('id'));
2323
if (parts) {
2424
positions = positions.concat({'id': parts[2], 'position': position});

0 commit comments

Comments
 (0)