首页 > 解决方案 > 无法运行 rails 服务器

问题描述

我正在尝试制作一个像这样非常简单的 Rails 程序。起初,我通过这个命令在 Rails 中做了一些事情:

rails generate scaffold Product \ title:string desciption:text image_url:string price:decimal

似乎一切运行正常,然后我运行这个命令没问题rails db:migrate,但是当我运行时我遇到rails server了这些问题

=> Booting Puma => Rails 6.0.1 application starting in development => Run rails server --help for more startup options *** SIGUSR2 not implemented, signal based restart unavailable! *** SIGUSR1 not implemented, signal based restart unavailable! *** SIGHUP not implemented, signal based logs reopening unavailable! Puma starting in single mode... * Version 4.3.0 (ruby 2.6.4-p104), codename: Mysterious Traveller * Min threads: 5, max threads: 5 * Environment: development * Listening on tcp://[::1]:3000 * Listening on tcp://127.0.0.1:3000 Use Ctrl-C to stop

Started GET "/products" for ::1 at 2019-12-03 14:29:37 +0700 (3.0ms) SELECT sqlite_version(*) (0.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC

SyntaxError (C:/Users/xxx/Desktop/xxx/X/app/controllers/products_controller.rb:72: syntax error, unexpected backslash, expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END ...ams.require(:product).permit(:\, :title, :desciption, :image... ...^):

app/controllers/products_controller.rb:72: syntax error, unexpected backslash, expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END app/controllers/products_controller.rb:72: syntax error, unexpected backslash, expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END app/controllers/products_controller.rb:72: syntax error, unexpected backslash, expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END

因为这个问题我很困惑?我是一个新手,正在尝试制作一个简单的程序,所以请帮助我,非常感谢。

标签: ruby-on-railsruby

解决方案


根据错误,products_controller在这一行中有一个错字

params.require(:product).permit(:\, :title, ...)

从列表中删除并重:\试。


推荐阅读