Anything in the public directory is rendered as a static asset, so no Ruby code in there.
Instead, you should remove the index.html file in that directory, and replace it with something else within your app. For example, you can do something like this:
# app/controllers/site_controller.rb
class SiteController < ApplicationController
def index
# ...
end
end
# config/routes.rb
root to: 'site#index'
# app/views/site/index.html.erb
<!-- Your HTML and Ruby here -->
This will give you the behavior you want.
http://stackoverflow.com/questions/18485429/rails-use-ruby-in-public-index