gpt4 book ai didi

ruby-on-rails - 语法错误,意外的 keyword_do_block,期待 keyword_end ...关闭

转载 作者:太空宇宙 更新时间:2023-11-03 16:22:53 24 4
gpt4 key购买 nike

我正在尝试开发具有某些日期形式的 redmine 插件。当我尝试配置路由设置时,rails 向我显示了这个错误。我无法修复它。问题出在哪里?

我得到了这个错误:

/days/new.html.erb:20: syntax error, unexpected tLABEL, expecting keyword_end ...ppend= form_for(@daysoff) url: {action: "create"} do |f| @o... ... ^ /var/www/redmine/plugins/days_off_redmine/app/views/days/new.html.erb:20: syntax error, unexpected keyword_do_block, expecting keyword_end ...off) url: {action: "create"} do |f| @output_buffer.safe_appe... ... ^ /var/www/redmine/plugins/days_off_redmine/app/views/days/new.html.erb:44: syntax error, unexpected keyword_ensure, expecting end-of-input

配置/routes.rb

get 'days_off_redmine', :to => 'days#index'
get 'days_off_redmine/new', :to => 'days#new'
post 'days_off_redmine', :to => 'days#create'

模型/daysoff.rb

class Daysoff < ActiveRecord::Base
unloadable
end

days_controller.rb

class DaysController < ApplicationController
unloadable

def index


end

def new
@people = User.all
@user = User.current

@daysoff = Daysoff.new
end

def create
end



end

天/index.html.erb

<%= link_to 'New', days_off_redmine_new_path %>

天/new.html.erb

<%= form_for(@daysoff) url: {action: "create"} do |f| %>
<%= f.date_field :date, id: 'altField' %>
<%= f.select_field "user", options_from_collection_for_select(@people, "id", "name"), prompt: "Select user" %>
<%= f.submit "Submit" %>
<% end %>

附加问题:其实我不需要额外的页面,如何将我的表单发布到索引 Controller 中?

最佳答案

你错过了 比如:

<%= form_for @daysoff, url: {action: "create"} do |f| %>

关于ruby-on-rails - 语法错误,意外的 keyword_do_block,期待 keyword_end ...关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31017274/

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