Skip to content

Instantly share code, notes, and snippets.

@ancap
Last active December 29, 2015 04:39
Show Gist options
  • Save ancap/7616833 to your computer and use it in GitHub Desktop.
Save ancap/7616833 to your computer and use it in GitHub Desktop.
Ruby on Rails "Hellow World" app.

Run:

rails g controller StaticPages index

In config/routes.rb add:

root "static_pages#index"

###Show variable contents from controller in view### ####Controller####

class StaticPagesController < ApplicationController
  def index
    @LOL = "OLOLO"
  end
end

####View####

<%= @LOL %>

###Request external page and show html###

require "open-uri"
class StaticPagesController < ApplicationController
  def index
  @response = open("http://ya.ru/").read
  end
end

In view:

<%= @response.html_safe %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment