[ruby on rails] script/consoleでアクションやヘルパーメソッドを実行

script/consoleでアクションを実行。

$ ./script/console 
Loading development environment (Rails 2.1.2)
>> app.get "/"
=> 200
>> app.response

script/consoleでヘルパーメソッドを実行。

$ ./script/console 
Loading development environment (Rails 2.1.2)
>> foo = ActionView::Base.new
=> #<ActionView::Base:0x220c310 @controller=nil, @finder=#<ActionView::TemplateFinder:0x220c2c0 @view_paths=[], @template=#<ActionView::Base:0x220c310 ...>>, @assigns_added=nil, @assigns={}>

>> foo.extend ApplicationHelper
=> #<ActionView::Base:0x220c310 @controller=nil, @finder=#<ActionView::TemplateFinder:0x220c2c0 @view_paths=[], @template=#<ActionView::Base:0x220c310 ...>>, @assigns_added=nil, @assigns={}>

>> foo.your_helper_method(args)
=> "<html>created by your helper</html>"

>> foo.extend YourHelperModule
=> #<ActionView::Base:0x220c310 @controller=nil, @finder=#<ActionView::TemplateFinder:0x220c2c0 @view_paths=[], @template=#<ActionView::Base:0x220c310 ...>>, @assigns_added=nil, @assigns={}>

>> foo.your_helper_method(args)
=> "<html>created by your helper</html>"

script/console で URL がどんな params に認識されるかを確かめる - d.hatena.ne.jp/jun66j5/

Firing a controller's action from the console [ruby] [rails] [controller] [action]

Misuse » Firing Rails Controller Actions from Command line (console)

How do I call controller/view methods from the console in Rails? - Stack Overflow

トラックバック(0)

このブログ記事を参照しているブログ一覧: script/consoleでアクションやヘルパーメソッドを実行

このブログ記事に対するトラックバックURL: http://www.pistolfly.jp/mt/mt-tb-alt.cgi/505

コメントする