Rails 3 - 错误 Errno::EINVAL:测试页面时参数无效

发布于 2024-12-07 08:17:39 字数 6872 浏览 0 评论 0原文

嗨, 我需要帮助。我在 Ruby on Rails 3 中开发了应用程序。它的简单应用程序包含一些 scadfolds 和仅对 mysql 数据库进行 CRUD 操作。因为我是 Windows 64 位用户,所以我有时会遇到一些 gems 的问题(例如 mysql2 gem 等)。但到目前为止我已经解决了所有问题。现在我的情况是,当我有应用程序时,并且当我在本地主机上测试它时,我在网络浏览器中收到此错误:

内部服务器错误 无效参数 WEBrick/1.3.1 (Ruby/1.8.7/2011-02-18) at localhost:300

Webrick 日志:

*Started GET "/?mobile=0" for 127.0.0.1 at Thu Sep 29 13:25:53 +0200 2011
DEPRECATION WARNING: Setting filter_parameter_logging in ActionController is deprecated and has no longer effect, please set 'config.filter_parameters' in config/application.rb instead. (called from C:/Sites/stodolist/app/controllers/application_controller.rb:8)
  Processing by UsersController#show as HTML
  Parameters: {"mobile"=>"0"}
  User Load (0.0ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
  SQL (1.0ms)  BEGIN
  AREL (1.0ms)  UPDATE `users` SET `updated_at` = '2011-09-29 11:25:53', `perishable_token` = '0Mp7RB1VTjml8S7Syqh', `last_request_at` = '2011-09-29 11:25:53' WHERE `users`.`id` = 1
  SQL (22.0ms)  COMMIT
  Task Load (2.0ms)  SELECT `tasks`.* FROM `tasks` WHERE (`tasks`.user_id = 1)
  Priority Load (0.0ms)  SELECT `priorities`.* FROM `priorities` WHERE `priorities`.`id` = 1 LIMIT 1
  Cathegory Load (1.0ms)  SELECT `cathegories`.* FROM `cathegories` WHERE `cathegories`.`id` = 1 LIMIT 1
  Status Load (1.0ms)  SELECT `statuses`.* FROM `statuses` WHERE `statuses`.`id` = 1 LIMIT 1
  Priority Load (1.0ms)  SELECT `priorities`.* FROM `priorities` WHERE `priorities`.`id` = 2 LIMIT 1
  Cathegory Load (1.0ms)  SELECT `cathegories`.* FROM `cathegories` WHERE `cathegories`.`id` = 2 *LIMIT 1
  CACHE (0.0ms)  SELECT `statuses`.* FROM `statuses` WHERE `statuses`.`id` = 1 LIMIT 1*
  Priority Load (0.0ms)  SELECT `priorities`.* FROM `priorities` WHERE `priorities`.`id` = 3 LIMIT 1
  Cathegory Load (0.0ms)  SELECT `cathegories`.* FROM `cathegories` WHERE `cathegories`.`id` = 3 LIMIT 1
  CACHE (0.0ms)  SELECT `statuses`.* FROM `statuses` WHERE `statuses`.`id` = 1 LIMIT 1
  0m  SELECT `priorities`.* FROM `priorities` WHERE `priorities`.`id` = 4 LIMIT 1
  CACHE (0.0ms)  SELECT `cathegories`.* FROM `cathegories` WHERE `cathegories`.`id` = 1 LIMIT 1
  CACHE (0.0ms)  SELECT `statuses`.* FROM `statuses` WHERE `statuses`.`id` = 1 LIMIT 1
  Timeline Load (1.0ms)  SELECT `timelines`.* FROM `timelines` WHERE (`timelines`.user_id = 1)
Rendered users/show.html.erb within layouts/application (421.0ms)
Completed 200 OK in 619ms (Views: 448.0ms | ActiveRecord: 32.0ms)
[2011-09-29 13:25:57] ERROR Errno::EINVAL: Invalid argument*
    *C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/railsrack/log_tailer.rb:25:in `write'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/rack/log_tailer.rb:25:in `print'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/rack/log_tailer.rb:25:in `tail!'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/rack/log_tailer.rb:15:in `call'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.2.3/lib/rack/content_length.rb:13:in `call'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.2.3/lib/rack/handler/webrick.rb:52:in `service'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:162:in `start'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:95:in `start'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:92:in `each'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:92:in `start'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:23:in `start'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:82:in `start'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.2.3/lib/rack/handler/webrick.rb:13:in `run'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.2.3/lib/rack/server.rb:217:in `start'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands/server.rb:65:in `start'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:30
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27
    script/rails:6:in `require'
    script/rails:6*

每次单击某些 link_to 时都会显示此错误

这是我的系统属性:

  1. Windows 7 x86
  2. Ruby/ 1.8.7/2011-02-10
  3. WEBrick/1.3.1
  4. Rails 3.0.7

我的路线:

resources :priorities
resources :timelines
resources :cathegories
resources :statuses
resources :user_sessions
resources :users
resource :user, :as => 'account'
resources :tasks  
match 'signup' => 'users#new', :as => :signup  
match 'admin' => "application#index",      :as => :admin  
match 'login' => "user_sessions#new",      :as => :login
match 'logout' => "user_sessions#destroy", :as => :logout

root :to => "users#show"

真的不知道错误在哪里:(我认为它可以在路线中... 我对愚蠢的问题感到抱歉,我是新手..

开发日志: 它很奇怪,因为服务器日志如下所示:

Started GET "/user" for 127.0.0.1 at Thu Sep 29 14:12:00 +0200 2011
DEPRECATION WARNING: Setting filter_parameter_logging in ActionController is deprecated and has no longer effect, please set 'config.filter_parameters' in config/application.rb instead. (called from C:/Sites/stodolist/app/controllers/application_controller.rb:8)
  Processing by UsersController#show as HTML
  [1m[35mUser Load (1.0ms)[0m  SELECT `users`.* FROM `users` WHERE `users`.`persistence_token` = '6e8fba00deefc7922358a3022942302058a31133d7b2dc98bcc1620a06869d36f81c5f42789da7e4fb7b36bddfd4ad628fe547fde111d9fe18af823e0698e8d5' LIMIT 1
  [1m[36mUser Load (2.0ms)[0m  [1mSELECT `users`.* FROM `users` WHERE `users`.`id` = 4 LIMIT 1[0m
  [1m[35mSQL (0.0ms)[0m  BEGIN
  [1m[36mAREL (0.0ms)[0m  [1mUPDATE `users` SET `updated_at` = '2011-09-29 12:12:01', `last_request_at` = '2011-09-29 12:12:01', `perishable_token` = 'v4g9FCSyQfuOAIFXfUQ' WHERE `users`.`id` = 4[0m
  [1m[35mSQL (82.0ms)[0m  COMMIT
  [1m[36mTask Load (1.0ms)[0m  [1mSELECT `tasks`.* FROM `tasks` WHERE (`tasks`.user_id = 4)[0m
  [1m[35mTimeline Load (1.0ms)[0m  SELECT `timelines`.* FROM `timelines` WHERE (`timelines`.user_id = 4)
Rendered users/show.html.erb within layouts/application (115.0ms)
Completed 200 OK in 321ms (Views: 143.0ms | ActiveRecord: 87.0ms)

Hio,
i need help. I developed application in Ruby on Rails 3. Its simple application witch some scadfolds and only CRUD operation on mysql database. Because I am Windows 64-bit user i have sometimes problems with some gems(for example mysql2 gem etc.). But until now I have solved every problem. Now i am in situation, when I have application, and already when I test it on localhost I get this error in web browser:

Internal Server Error
Invalid argument
WEBrick/1.3.1 (Ruby/1.8.7/2011-02-18) at localhost:300

Webrick log:

*Started GET "/?mobile=0" for 127.0.0.1 at Thu Sep 29 13:25:53 +0200 2011
DEPRECATION WARNING: Setting filter_parameter_logging in ActionController is deprecated and has no longer effect, please set 'config.filter_parameters' in config/application.rb instead. (called from C:/Sites/stodolist/app/controllers/application_controller.rb:8)
  Processing by UsersController#show as HTML
  Parameters: {"mobile"=>"0"}
  User Load (0.0ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
  SQL (1.0ms)  BEGIN
  AREL (1.0ms)  UPDATE `users` SET `updated_at` = '2011-09-29 11:25:53', `perishable_token` = '0Mp7RB1VTjml8S7Syqh', `last_request_at` = '2011-09-29 11:25:53' WHERE `users`.`id` = 1
  SQL (22.0ms)  COMMIT
  Task Load (2.0ms)  SELECT `tasks`.* FROM `tasks` WHERE (`tasks`.user_id = 1)
  Priority Load (0.0ms)  SELECT `priorities`.* FROM `priorities` WHERE `priorities`.`id` = 1 LIMIT 1
  Cathegory Load (1.0ms)  SELECT `cathegories`.* FROM `cathegories` WHERE `cathegories`.`id` = 1 LIMIT 1
  Status Load (1.0ms)  SELECT `statuses`.* FROM `statuses` WHERE `statuses`.`id` = 1 LIMIT 1
  Priority Load (1.0ms)  SELECT `priorities`.* FROM `priorities` WHERE `priorities`.`id` = 2 LIMIT 1
  Cathegory Load (1.0ms)  SELECT `cathegories`.* FROM `cathegories` WHERE `cathegories`.`id` = 2 *LIMIT 1
  CACHE (0.0ms)  SELECT `statuses`.* FROM `statuses` WHERE `statuses`.`id` = 1 LIMIT 1*
  Priority Load (0.0ms)  SELECT `priorities`.* FROM `priorities` WHERE `priorities`.`id` = 3 LIMIT 1
  Cathegory Load (0.0ms)  SELECT `cathegories`.* FROM `cathegories` WHERE `cathegories`.`id` = 3 LIMIT 1
  CACHE (0.0ms)  SELECT `statuses`.* FROM `statuses` WHERE `statuses`.`id` = 1 LIMIT 1
  0m  SELECT `priorities`.* FROM `priorities` WHERE `priorities`.`id` = 4 LIMIT 1
  CACHE (0.0ms)  SELECT `cathegories`.* FROM `cathegories` WHERE `cathegories`.`id` = 1 LIMIT 1
  CACHE (0.0ms)  SELECT `statuses`.* FROM `statuses` WHERE `statuses`.`id` = 1 LIMIT 1
  Timeline Load (1.0ms)  SELECT `timelines`.* FROM `timelines` WHERE (`timelines`.user_id = 1)
Rendered users/show.html.erb within layouts/application (421.0ms)
Completed 200 OK in 619ms (Views: 448.0ms | ActiveRecord: 32.0ms)
[2011-09-29 13:25:57] ERROR Errno::EINVAL: Invalid argument*
    *C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/railsrack/log_tailer.rb:25:in `write'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/rack/log_tailer.rb:25:in `print'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/rack/log_tailer.rb:25:in `tail!'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/rack/log_tailer.rb:15:in `call'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.2.3/lib/rack/content_length.rb:13:in `call'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.2.3/lib/rack/handler/webrick.rb:52:in `service'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:162:in `start'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:95:in `start'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:92:in `each'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:92:in `start'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:23:in `start'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/webrick/server.rb:82:in `start'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.2.3/lib/rack/handler/webrick.rb:13:in `run'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.2.3/lib/rack/server.rb:217:in `start'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands/server.rb:65:in `start'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:30
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
    C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27
    script/rails:6:in `require'
    script/rails:6*

This error shows everytime when I click on some link_to

Here is my system properties:

  1. Windows 7 x86
  2. Ruby/1.8.7/2011-02-10
  3. WEBrick/1.3.1
  4. Rails 3.0.7

My routes:

resources :priorities
resources :timelines
resources :cathegories
resources :statuses
resources :user_sessions
resources :users
resource :user, :as => 'account'
resources :tasks  
match 'signup' => 'users#new', :as => :signup  
match 'admin' => "application#index",      :as => :admin  
match 'login' => "user_sessions#new",      :as => :login
match 'logout' => "user_sessions#destroy", :as => :logout

root :to => "users#show"

Really dont no where is the error:( I think it can be in routes...
I'm sry for stupid question, I'm newbie..

Development log:
its weird becouse server log look like this:

Started GET "/user" for 127.0.0.1 at Thu Sep 29 14:12:00 +0200 2011
DEPRECATION WARNING: Setting filter_parameter_logging in ActionController is deprecated and has no longer effect, please set 'config.filter_parameters' in config/application.rb instead. (called from C:/Sites/stodolist/app/controllers/application_controller.rb:8)
  Processing by UsersController#show as HTML
  [1m[35mUser Load (1.0ms)[0m  SELECT `users`.* FROM `users` WHERE `users`.`persistence_token` = '6e8fba00deefc7922358a3022942302058a31133d7b2dc98bcc1620a06869d36f81c5f42789da7e4fb7b36bddfd4ad628fe547fde111d9fe18af823e0698e8d5' LIMIT 1
  [1m[36mUser Load (2.0ms)[0m  [1mSELECT `users`.* FROM `users` WHERE `users`.`id` = 4 LIMIT 1[0m
  [1m[35mSQL (0.0ms)[0m  BEGIN
  [1m[36mAREL (0.0ms)[0m  [1mUPDATE `users` SET `updated_at` = '2011-09-29 12:12:01', `last_request_at` = '2011-09-29 12:12:01', `perishable_token` = 'v4g9FCSyQfuOAIFXfUQ' WHERE `users`.`id` = 4[0m
  [1m[35mSQL (82.0ms)[0m  COMMIT
  [1m[36mTask Load (1.0ms)[0m  [1mSELECT `tasks`.* FROM `tasks` WHERE (`tasks`.user_id = 4)[0m
  [1m[35mTimeline Load (1.0ms)[0m  SELECT `timelines`.* FROM `timelines` WHERE (`timelines`.user_id = 4)
Rendered users/show.html.erb within layouts/application (115.0ms)
Completed 200 OK in 321ms (Views: 143.0ms | ActiveRecord: 87.0ms)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

揪着可爱 2024-12-14 08:17:39

好的,我找到了这个问题的解决方案。我决定将我的网络服务器更改为 morgel。经过两个小时的工作,没有出现任何错误。也许这个问题真的取决于我的环境 - Win 64bit/ruby/mysql/rails3 和 webrick。我会看看事情进展如何...

Ok, i found solution of this prob. I decided to change my webserver to morgel. After two hours of working, no error. Maybe this issue really depand on my enviroment- Win 64bit/ruby/mysql/rails3 and webrick. I will see how its going...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文