Rails服务器减少冗长?

时间:2011-06-02 06:42:03

标签: ruby-on-rails

我从Django学到的控制器中的一种调试方法是实际打印出控制器本身的变量。但是,我意识到这种方法在rails中并不实用,因为默认的rails webserver非常冗长,而且这让我很难追踪。

仅供参考我阅读了有关rails调试页面的内容,但大多数调试技术都存在于VIEW层中(例如<%@ myvar.debug%>)。我希望能够看到控制器内的变量状态,我不想使用rails调试器,因为它对于这么简单的东西来说太过分了。

我的问题是:是否有一个变量可以设置为减少每个页面服务生成的语句,如下所示?

Started POST "/submissions" for 127.0.0.1 at 2011-06-02 02:35:38 -0400
  Processing by SubmissionsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"U+I2mSfCRFvOyT/L82TTzsVRVJQuJbB+X3SaMWr/IM4=", "submission"=>{"url"=>"http://wasdvasd.com", "receiver_id"=>"1", "comment"=>"asdvasdvasdv"}, "commit"=>"Create Submission"}
  User Load (0.5ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
  Link Load (0.1ms)  SELECT "links".* FROM "links" WHERE "links"."url" = 'http://wasdvasd.com' LIMIT 1
  AREL (0.3ms)  INSERT INTO "links" ("url", "created_at", "updated_at") VALUES ('http://wasdvasd.com', '2011-06-02 06:35:38.399463', '2011-06-02 06:35:38.399463')
  AREL (0.2ms)  INSERT INTO "submissions" ("link_id", "author_id", "receiver_id", "comment", "visited", "created_at", "updated_at") VALUES (5, 1, 1, 'asdvasdvasdv', NULL, '2011-06-02 06:35:38.402094', '2011-06-02 06:35:38.402094')
Redirected to http://localhost:3000/submissions
Completed 302 Found in 244ms

1 个答案:

答案 0 :(得分:1)

您应该可以更改config/environments/*.rb文件中的日志记录级别。

请参阅:http://guides.rubyonrails.org/debugging_rails_applications.html#log-levels了解不同的日志级别。