将参数传递给苗条的部分
Passing params to a partial in slim
Rails 3.2
Ruby 2.15
我的看法有些复杂app/views/tickets/show。html.slim。在这个视图中,我渲染了票的各个部分
一节叫做customer_info。这是我拥有的:
render 'tickets/sections/customer_info', locals: { customer_info: CustomerInfo.new, ticket: @ticket }
在我的 app/views/tickets/sections/_customer_info.html.slim 中,我有:
= form_for(customer_info) do |f|
- :ticket_id = ticket.id
= f.hidden_field :ticket_id
.form-horizontal-column.customer-info
.form-group
= f.label :first_name
= f.text_field :first_name
.form-group
= f.label :last_name
= f.text_field :last_name
.actions = f.submit 'Save'
.clear
但是我收到以下错误消息:
_customer_info.html.slim:2: syntax error, unexpected '=', expecting keyword_end
; :ticket_id = ticket.id;
^
我开始学习 .slim。有什么想法吗?
您不能为某物设置符号 - 它们是不可变的。你可以删除第二行做类似的事情:
= form_for(customer_info) do |f|
= f.hidden_field :ticket_id, :value => ticket.id
...
Rails 3.2
Ruby 2.15
我的看法有些复杂app/views/tickets/show。html.slim。在这个视图中,我渲染了票的各个部分
一节叫做customer_info。这是我拥有的:
render 'tickets/sections/customer_info', locals: { customer_info: CustomerInfo.new, ticket: @ticket }
在我的 app/views/tickets/sections/_customer_info.html.slim 中,我有:
= form_for(customer_info) do |f|
- :ticket_id = ticket.id
= f.hidden_field :ticket_id
.form-horizontal-column.customer-info
.form-group
= f.label :first_name
= f.text_field :first_name
.form-group
= f.label :last_name
= f.text_field :last_name
.actions = f.submit 'Save'
.clear
但是我收到以下错误消息:
_customer_info.html.slim:2: syntax error, unexpected '=', expecting keyword_end
; :ticket_id = ticket.id;
^
我开始学习 .slim。有什么想法吗?
您不能为某物设置符号 - 它们是不可变的。你可以删除第二行做类似的事情:
= form_for(customer_info) do |f|
= f.hidden_field :ticket_id, :value => ticket.id
...