将params传递给苗条的部分

时间:2016-06-07 01:05:41

标签: ruby-on-rails slim-lang

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。有什么想法吗?

1 个答案:

答案 0 :(得分:1)

您无法设置符号 - 它们是不可变的。你可以删除第二行做类似的事情:

= form_for(customer_info) do |f|
  = f.hidden_field :ticket_id, :value => ticket.id
  ...