アクションを実行するときにページを開こうとしています。したがって、コントローラーには次のものがあります。
class Controller < ApplicationController
require 'open-uri'
def action
open("http://www.google.com") #if i use this, it just goes to my action page
open("www.google.com") #if i use this, it gives the error
end
end
エラー:
Errno::ENOENT in Controller#action
No such file or directory - www.google.com
私が見つけたすべてのソリューションには、require 'open-uri' が含まれていると言われています。ここで何が間違っていますか?
編集:
申し訳ありませんが、もっと明確にする必要がありました。新しいタブで複数のページを開く必要がある場合があるため、redirect_to の代わりに open を使用することにしました。例えば:
class Controller < ApplicationController
require 'open-uri'
def action
open("http://www.google.com")
open("http://www.yahoo.com")
end
end
これを行うと、google.com と yahoo.com の両方が開きます。