我正在尝试升级此博客文章中显示的示例
https://medium.com/@mitch_23203/the-exact-same-app-in-hyperstack-7f281cef46ca
使用超级堆栈模型(如后续博客文章),但这是行不通的。
更改后,这是我的代码:
class TodoIndex < HyperComponent
def create_new_todo_item
Todo.create(title: @todo)
@title = nil
end
render(DIV, class: 'ToDo') do
IMG(class: 'Logo', src: 'assets/logo.png', alt: 'Hyperstack Logo')
H1(class: 'ToDo-Header') { 'Hyperstack To Do' }
DIV(class: 'ToDo-Container') do
DIV(class: 'ToDo-Content') do
Todo.each do |item|
TodoItem(key: item, item: item.title)
.on(:delete_item) { item.destroy }
end
end
DIV do
INPUT(type: :text, value: @title)
.on(:change) { |e| mutate @title = e.target.value }
.on(:enter) { create_new_todo_item }
BUTTON(class: 'ToDo-Add') { '+' }
.on(:click) { create_new_todo_item }
end
end
end
end
一切似乎都正常,并且保存了新的Todo,但属性为nil。好像标题没有保存。
答案 0 :(得分:4)
应该是:
orders
您将SELECT
tot_owed.clientname
, tot_owed.Total_Owed
- IIF(tot_paid.Total_Paid IS NULL, 0, tot_paid.Total_Paid) AS Balance
FROM (
SELECT
c.clientname
, c.clientnumber
, SUM(i.orderamount * i.itemprice) AS Total_Owed
FROM
clients c
INNER JOIN
orders o ON c.clientnumber = o.clientnumber
INNER JOIN
orderinfo i ON i.ordernum = o.ordernum
GROUP BY
c.clientname
, c.clientnumber
) tot_owed
LEFT JOIN (
SELECT
c.clientname
, c.clientnumber
, SUM(p.payment) AS Total_Paid
FROM
clients c
INNER JOIN
payments p ON c.clientnumber = p.clientnumber
GROUP BY
c.clientname
, c.clientnumber
) tot_paid ON tot_owed.clientnumber = tot_paid.clientnumber
中的def create_new_todo_item
Todo.create(title: @title) # not @todo
@title = nil
end
设置为其状态值(title
)...