ruby-on-rails - 无法运行 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
因为这个问题我很困惑?我是一个新手,正在尝试制作一个简单的程序,所以请帮助我,非常感谢。
解决方案
根据错误,products_controller
在这一行中有一个错字
params.require(:product).permit(:\, :title, ...)
从列表中删除并重:\
试。
推荐阅读
- python - 如何在 KivyMD 屏幕之间传递参数?
- ffmpeg - 无法解析 com.android.tools.build:gradle:4.0.1
- java - 无法在 Eclipse 上创建与已删除项目同名的新动态 Web 项目
- vb.net - 如何在 Net5 中读取配置文件?
- html - 如何在 Django 模板中重新定位表单按钮
- laravel - 使用 Storage::makeDirectory() 不在 laravel 中创建文件夹
- php - 执行检查数据功能后 sqlsrv_query 不返回任何结果
- python - 将数据转换为网络的矩阵
- docker - Windows 中启动时出现 Docker 错误。附加异常
- python - 无法定位元素:{"method":"css selector","selector":".Mr508"}