Skip to content

Commit

Permalink
#27 show place
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Sep 9, 2018
1 parent dd443c1 commit 67f8084
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions objects/letter.rb
Expand Up @@ -89,6 +89,10 @@ def toggle
@hash = {}
end

def place
(@hash['place'] || @pgsql.exec('SELECT place FROM letter WHERE id=$1', [@id])[0]['place']).to_i
end

def move(inc = 1)
@pgsql.exec('UPDATE letter SET place=place + $1 WHERE id = $2', [inc, @id])
@hash = {}
Expand Down
1 change: 1 addition & 0 deletions views/lane.haml
Expand Up @@ -41,6 +41,7 @@
%span{class: ('cross' unless r.active?)}
&= r.title
%br
%span.item.small= '%+d' % r.place
%a.item.small{href: "/letter-up?id=#{r.id}"} Up
%a.item.small{href: "/letter-down?id=#{r.id}"} Down

0 comments on commit 67f8084

Please sign in to comment.