4

I put up my rails application on AWS elastic beanstalk through Amazon's eb tool. On elastic beanstalk, I'm using its default load balancer, and am running ubuntu 64bit with ruby 2.0.

I'm getting two major problems:

1) the root route isn't working.

  • In my config/routes.rb, I tried:

    root 'controller#action
    root :to => 'controller#action'
    root to: 'controller#action'

    and found none of them working. The server was giving me an error saying that:

    Invalid route name, already in use: 'root' (ArgumentError)

  • I guessed that there was some kind of clash between Rail's default root=>public/index.html and my own routing in config/routes.rb? So I created public/index.html and the root url '/' now serves public/index.html. I want to figure out a way to make it work the 'Rails' way, with the root url routing to controller#action.

2) Static assets are not being served.

Does anyone know the solutions for these problems?

Thank You in advance!

========================= Edit ===========================

I'm using Amazon 64bit Linux with Passenger Standalone

Se Won Jang
  • 773
  • 1
  • 5
  • 12
  • Can you please tell the exact name solution stack you are using? Is it "64bit Amazon Linux 2014.03 v1.0.4 running Ruby 2.0 (Puma)" or some other version. Can you try with this latest version? – Rohit Banga Jul 09 '14 at 05:59
  • I added it to the question! – Se Won Jang Jul 09 '14 at 06:25
  • Can you try the latest solution stack version for passenger standalone - currently v1.0.3. The exact solution stack name is "64bit Amazon Linux 2014.03 v1.0.3 running Ruby 2.0 (Passenger Standalone)"? – Rohit Banga Jul 09 '14 at 06:29
  • Yeah that's what I'm using right now, Sorry I wasn't specific enough! And my local dev env is also Ruby 2.0 – Se Won Jang Jul 09 '14 at 06:30
  • For (1) can you try what is suggested here: http://stackoverflow.com/a/24222282/161628 – Rohit Banga Jul 09 '14 at 06:40
  • I tried many different routes.rb conventions, but none of them worked in the production environment when staged on elastic beanstalk – Se Won Jang Jul 09 '14 at 07:11

1 Answers1

0

Try the following:

config/routes.rb

Rails.application.routes.draw do
  root 'home#index'
end

Remove or comment out all definitions of '/' (including get '/', match '/', etc.)

app/controllers/home_controller.rb

class HomeController < ApplicationController

  def index
    render 'index'
  end

end

app/views/home/index.html.erb

<h1>HELLO WORLD.</h1>

And make sure to delete public/index.html.

Eric Tjossem
  • 2,536
  • 1
  • 15
  • 18