Skip to content

Commit cf888c5

Browse files
committed
Correct POST form
1 parent ad33dc0 commit cf888c5

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

app/models/register_coauthor.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,21 @@ class RegisterCoauthor < ApplicationRecord
99

1010
after_destroy(:update_coauthors_order)
1111

12+
##
13+
# Is this the first coauthor? Note that this means this is the
14+
# second author of the list (since the submitting user is always
15+
# first in the list of authors)
16+
def first?
17+
order == 1
18+
end
19+
20+
##
21+
# Move the coauthor one position up in the order of coauthors
1222
def move_up
1323
return if order <= 1
1424

15-
register.register_coauthor.where(order: order - 1)
25+
register
26+
.register_coauthor.where(order: order - 1)
1627
.update(order: order) && update(order: order - 1)
1728
end
1829

app/views/registers/coauthors.html.erb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,19 @@
2323
<%= display_link(author) %>
2424
<%= link_to(
2525
coauthors_register_url(
26-
@register, coauthor: author.username, action: :unlink),
26+
@register, action: :unlink,
27+
register: { coauthor: author.username }),
2728
class: 'badge badge-pill badge-primary',
2829
method: :post, title: 'Unlink coauthor',
2930
data: { confirm: 'Are you sure?' }
3031
) do %>
3132
<%= fa_icon('unlink') %> Remove as coauthor
3233
<% end %>
33-
<% unless rc.order == 1 %>
34+
<% unless rc.first? %>
3435
<%= link_to(
3536
coauthors_register_url(
36-
@register, coauthor: author.username, action: :up),
37+
@register, action: :up,
38+
register: { coauthor: author.username }),
3739
class: 'badge badge-pill badge-primary',
3840
method: :post, title: 'Move coauthor up'
3941
) do %>

0 commit comments

Comments
 (0)