从Rails控制台调用ActionController方法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从Rails控制台调用ActionController方法相关的知识,希望对你有一定的参考价值。

The 'request' and 'response' objects are chock full of useful info. But console can't usually access them. Here's how:
start the server with the -u option, insert a breakpoint where you would like to have access to the controllers/helpers/etc. When finished, just type 'cont' to continue execution
  1. # terminal
  2. script/server -u
  3.  
  4. # /some/view.erb
  5. <% debugger %>
  6.  
  7. # open the url associated with that view, and switch over to the terminal to play with ActionController methods and objects
  8. (rdb:2) request

以上是关于从Rails控制台调用ActionController方法的主要内容,如果未能解决你的问题,请参考以下文章

从Rails控制台调用ActionController方法

Ruby on Rails - 从视图调用控制器方法

从 Rails 控制台重新加载帮助程序

从 Rails 中的控制器调用辅助方法时出现“未定义的方法”

rails如何从命令行调用运行本地服务器的控制器操作[重复]

如何从 Rails 中的控制器混入和调用 link_to?