gpt4 book ai didi

ruby-on-rails - Rails slim form_for 标签

转载 作者:行者123 更新时间:2023-12-01 10:45:31 25 4
gpt4 key购买 nike

从常规 ERB 切换到精简文件后,我无法使用表格。这是我尝试进行 slim 渲染的形式:

= form_for @student, :url => students_path(@student), method: :post do |f|
= f.hidden_field :student_id, :value => current_user.id
= f.hidden_field :course_id, :value => group.id
= submit_tag "Join this Class!", :class => "btn btn-primary pull-right join-button"

这是常规 ERB 文件中的工作代码

<%= form_for @student, :url => students_path(@student), method: :post do |f| %>
<%= f.hidden_field :student_id, :value => current_user.id %>
<%= f.hidden_field :course_id, :value => group.id %>
<%= submit_tag "+ Join", :class => "btn btn-primary pull-right join-button" %>
<% end %>

这是我目前遇到的错误:

undefined local variable or method `f'

最佳答案

slim 的最大问题是缩进试试这个(form_for 后的两个空格):

= form_for @student, :url => students_path(@student), method: :post do |f|
= f.hidden_field :student_id, :value => current_user.id
= f.hidden_field :course_id, :value => group.id
= submit_tag "Join this Class!", :class => "btn btn-primary pull-right join-button"

关于ruby-on-rails - Rails slim form_for 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26914923/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com