Palak Chaudhary
Palak Chaudhary

Reputation: 191

Script to open a URL in chrome browser in rails

I want to write a script to run in rails console so that whenever I hit a URL, instead of giving the result as response, I want something to be triggered so that the URL is opened in chrome browser.

Example:

def open_url_in_chrome_browser(url)

end

When the function is called, the URL should open in chrome.

Upvotes: 0

Views: 915

Answers (1)

abhsss96
abhsss96

Reputation: 353

You can do it by using this command on ubuntu machine.

exec("google-chrome www.google.com")

you can also define a method like for your local machine like this

def open_url_in_chrome_browser(url)
  exec("google-chrome www.google.com")
end

Upvotes: 1

Related Questions