我正在关注这个 Rails 教程:http: //guides.rubyonrails.org/getting_started.html我已经到了 5.2 中更改线路的部分
<%= form_for :post do |f| %>
至
<%= form_for :post, url: posts_path do |f| %>
每次我改变它,我都会收到这个错误:
SyntaxError in Posts#new
Showing /home/hiram/rails/blog/app/views/posts/new.html.erb where line #2 raised:
compile error
/home/hiram/rails/blog/app/views/posts/new.html.erb:2: syntax error, unexpected ':', expecting kEND
....append= form_for :post, url: posts_path do |f| @output_buf...
^
Extracted source (around line #2):
1: <h1>New Post</h1>
2: <%= form_for :post, url: posts_path do |f| %>
3: <p>
4: <%= f.label :title %><br>
5: <%= f.text_field :title %>
Trace of template inclusion: app/views/posts/new.html.erb
Rails.root: /home/hiram/rails/blog