Deploying Rails with Elastic Beanstalk 404 Not Found Error - ruby-on-rails

I'm trying to deploy my Ruby on Rails app with Elastic Beanstalk. I was following this guide - http://ruby.awsblog.com/post/Tx2AK2MFX0QHRIO/Deploying-Ruby-Applications-to-AWS-Elastic-Beanstalk-with-Git
But unfortunately, when I go to the site it shows
404 Not Found
nginx/1.4.3
eb status --verbose gives this:
Retrieving status of environment "SurveyMe".
URL : SurveyMe-i5dkejjacp.elasticbeanstalk.com
Status : Ready
Health : Green
Environment Name: SurveyMe
Environment ID : e-rtzrvemw53
Environment Tier: WebServer::Standard::1.0
Solution Stack : 64bit Amazon Linux 2013.09 running Ruby 1.9.3
Version Label : git-b2f153a095a4392b2c77a9e40a3bd91acf02757e-1391723347993
Date Created : 2014-02-06 21:36:28
Date Updated : 2014-02-06 21:49:37
Description :
I saw a few questions with a similar problem but most had errors here. Any ideas what might be going on or what to check? The app is currently deployed with Heroku - could that be an issue?
Including my routes.rb
SurveyMe::Application.routes.draw do
devise_for :developers
devise_for :users
mount Rapidfire::Engine => "/surveys"
root :to => "static_pages#home"
match "/about", to: "static_pages#use", via: "get"
match "/developers", to: "static_pages#developer" , via: "get"
match "/how", to: "static_pages#how", via: "get"

Assuming it's Rails application. Check your routes under:
<your app dir>/config/routes.rb
You should have something defined for the root route:
# Application home
root :to => 'welcome#index'

Related

Routting error in rails-cpanel

I deployed rails application in cPanel and run rails project but always server return to me this error:
No route matches "/index.html.var" with {:method=>:get}
http://railsbama.tk/
Notice: this project is hello world and has one controller('home') and one action 'index' only return 'hello world'.
Try setting your root path to the controller and action: root to: 'home#index'

404 Not Found error in deploying rails 3.2.12 app (with engines) to SUB URI on nginx/passenger

We need to deploy a rails 3.2.12 app to sub uri nbhy on a ubuntu 12.04 server. The rails app has 3 engines and one of them is authentify which is for user authentication. The main app's root pointing to authentify's signin page. Here is the routes.rb in main app:
root :to => "authentify::sessions#new"
match '/signin', :to => 'authentify::sessions#new'
match '/signout', :to => 'authentify::sessions#destroy'
match '/user_menus', :to => 'user_menus#index'
match '/view_handler', :to => 'authentify::application#view_handler'
The app is deployed to base uri nbhy running on ubuntu 12.04 with passenger and nginx. On the same server, there is another rails app running in its own sub uri. Here is the configuration in nginx.conf for sub uri nbhy:
server {
listen 80;
server_name 6.95.225.93;
root /var/www/;
passenger_enabled on;
rails_env production;
passenger_base_uri /by;
passenger_base_uri /nbhy;
#for rails >=3.1, assets pipeline
location ~ ^/assets/ {
expires max;
add_header Cache-Control public;
add_header ETag "";
break;
}
}
Also a symlink nbhy is created at document root /var/www pointing to /var/www/nbhyop/current/public. Here is the output of the root /var/www/:
total 8
lrwxrwxrwx 1 cjadmin www-data 28 Nov 3 2012 by -> /var/www/byop/current/public
drwxrwsr-x 4 cjadmin www-data 4096 Nov 4 2012 byop
lrwxrwxrwx 1 cjadmin www-data 30 May 16 21:27 nbhy -> /var/www/nbhyop/current/public
drwxrwsr-x 4 cjadmin www-data 4096 May 14 15:21 nbhyop
The by is the first rails app deployed to the sub URI and is working fine.
The login page is displayed after typing http://6.95.225.93/nbhy. After key in user and password, the page was redirected to http://6.95.225.93/authentify/session with 404 Not Found error. There is an error found in nginx error.log:
2013/05/13 16:29:25 [error] 2384#0: *1 open() "/var/www/authentify/session" failed (2: No such file or directory), client: 192.168.1.1, server: 6.95.225.93, request: "POST /authentify/session HTTP/1.1", host: "6.95.225.93", referrer: "http://6.95.225.93/nbhy/"
Obviously /var/www/authentify/session will not hit the right page because it is missing the base uri nbhy between www and authentify. Based on our analysis, the create in authentify session controller hasn't been hit and the user hasn't been authenticated even with the right user name and password at http://6.95.225.93/nbhy.
Also find out that a user can login at http://6.95.225.93/nbhy/authentify/session/new with some twist. After login the page will be redirected to http://6.95.225.93/user_menus which will throw out 404 Not Found error. However if we insert nbhy in between as : http://6.95.225.93/nbhy/user_menus, then it will bring up the user menus page successfully. For any further click on links, manually inserting nbhy will make the link work (if nbhy is missing).
The rails app worked fine when deploying without sub uri.
Why the sub uri is missing from route? Is there a way we can make the nbhy here to stay and eliminate the error? Thanks for help.
Most likely the authentify engine is doing a redirect to /user_menus, instead of /nbhy/authentify. Is this a custom Rails or Sinatra app that you have written? If so, you need to change/configure the code of authentify to always append the current subdirectory under which the Rails app is hosted. You can get that from passenger by saying ENV['RAILS_RELATIVE_URL_ROOT'] in your code.
Rails is generating paths straight from http://6.95.225.93 instead of http://6.95.225.93/nbhy.
You probably need to scope all your routes to "/nbhy".
config/routes.rb
scope "/nbhy" do
...
end

Rails 500 Error Visiting Resources [duplicate]

This question already has answers here:
500 internal server error in ruby on rails
(3 answers)
Closed 9 years ago.
On my localhost, my app works fine. On production server (Heroku) when I visit a resources page: http://startupcrawler.com/startups I get a 500 error.
Here's my routes.rb:
StartupcrawlerRuby::Application.routes.draw do
resources :startups
get "home/index"
root to: 'home#index'
end
And on my production server, here's what I get when I run rake routes:
Prefix Verb URI Pattern Controller#Action
startups GET /startups(.:format) startups#index
POST /startups(.:format) startups#create
new_startup GET /startups/new(.:format) startups#new
edit_startup GET /startups/:id/edit(.:format) startups#edit
startup GET /startups/:id(.:format) startups#show
PATCH /startups/:id(.:format) startups#update
PUT /startups/:id(.:format) startups#update
DELETE /startups/:id(.:format) startups#destroy
home_index GET /home/index(.:format) home#index
root GET /
Anything else I should check to fix this problem?
run heroku logs -t within project dir and try visit your resource.

ActionView::MissingTemplate Error on Rails 3.1 Application on Site5 hosting

Hello Everyone,
I am experiencing a strange problem when deploying a Rails 3.1 application running on phusion passenger.The problem have been bugging me for over 3 days now and I cannot seem to debug the error which is causing this error.
In controllers I have a folder by the name of admin and it contains controllers that are specific to backend admin section only. The routes are defined like this in the routes.rb file :
namespace :admin do
resources :users
match "dashboard/show" => "dashboard#show"
match "access/login" => "access#login"
match "access/attempt_login" => "access#attempt_login"
root :to => "access#login"
end
There is no error at all when the application is running in development environment on my mac however the application is giving 500 internal error when the application is deployed via capistrano. Please see the error below :
Started GET "/admin" for 110.39.204.79 at Sun Mar 04 06:48:23 -0600 2012
Processing by Admin::AccessController#login as HTML
Completed 500 Internal Server Error in 26ms
ActionView::MissingTemplate (Missing template admin/access/login with {:locale=>[:en, :en], :formats=>[:html], :handlers=>[:erb, :builder]}. Searched in:
* "/home/devacity/acitywithquirk/releases/20120304124458/app/views"
* "/home/devacity/acitywithquirk/releases/20120304124458/vendor/bundle/ruby/1.8/gems/devise-2.0.4/app/views"
* "/home/devacity/acitywithquirk/releases/20120304124458"
Started GET "/admin/dashboard" for 114.76.86.94 at Mon Mar 05 15:15:19 -0600 2012
ActionController::RoutingError (No route matches [GET] "/admin/dashboard"):
* "/"
):
app/controllers/admin/access_controller.rb:14:in `login'
I have spent copious amount of time in trying to resolve the issue but it I am not able to.Any help would be appreciated.
Thanks
you may check your svn commit. If not added to svn, it won't be deployed.
Check if the file exists. Also: I've had this error before when I was using haml, but it was only in the assets group, so not included on production (note that your formats only include erb and builder). Once I moved haml-rails out of the :assets group in the Gemfile it worked fine.

Rails: Omniauth: Github provider doesn't quite work

I recently forked https://github.com/fortuity/rails3-mongoid-omniauth and tried to get login working for different providers. It works for Twitter and Facebook (You can try it out at http://jgodse-omniauth-mongoid.heroku.com/), but I couldn't get it working for Github. The code snapshot is here at github.
My environment looks like this:
$ heroku info
=== jgodse-omniauth-mongoid
Web URL: http://jgodse-omniauth-mongoid.heroku.com/
Git Repo: git#heroku.com:jgodse-omniauth-mongoid.git
Dynos: 1
Workers: 0
Repo size: 7M
Slug size: 5M
Stack: bamboo-mri-1.9.2
Data size: (empty)
Addons: Basic Logging, MongoHQ MongoHQ Free, Shared Database 5MB
Owner: xxxxx#yyy.com
Jay#JAY-PC ~/rapps/rails3-mongoid-omniauth (master)
$ heroku config --long
BUNDLE_WITHOUT => development:test
DATABASE_URL => postgres://xxxxxxxxxxxxxxxxxxxx.compute-1.amazonaws.com/rrretnhwhj
FACEBOOK_APP_ID => xxxxxxxxxxxxxxxxxxxx
FACEBOOK_APP_SECRET => xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
GITHUB_CLIENT_ID => xxxxxxxxxxxxxxxxxxxxx
GITHUB_SECRET => xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
LANG => en_US.UTF-8
MONGOHQ_URL => mongodb://heroku:9xxxxxxxxxxxxxxxx.mongohq.com:27098/app527030
RACK_ENV => production
SHARED_DATABASE_URL => postgres://xxxxxxxxxxxxxxxxxxxxx.compute-1.amazonaws.com/rrretnhwhj
TWITTER_KEY => xxxxxxxxxxxxxxxxxxx
TWITTER_SECRET => xxxxxxxxxxxxxxxxxxxxxxxxxxxx
My github information for "OAuth Application: Jay's Rails3 Mongoid OAuth" is as follows (from my app profile page):
Authorization Token: https://github.com/login/oauth/authorize
Access Token URL: https://github.com/login/oauth/access_token
URL: http://jgodse-omniauth-mongoid.heroku.com/
Callback URL: http://jgodse-omniauth-mongoid.heroku.com/
Client ID: xxxxxxx
Secret: xxxxxxxxxxxxxxxx
The client and secret are set as environment variables in omniauth.rb
The authentication happens, but it redirects to http://jgodse-omniauth-mongoid.heroku.com/?error=redirect_uri_mismatch and I haven't apparently logged in. If I change the Callback URL to http://jgodse-omniauth-mongoid.heroku.com/callback, the application crashes.
What am I missing to get github authentication to work?
I don't fu%^&*g believe this.
I went to github.com where the application secret, key, url, callback is configured and removed the trailing slash from the "Callback URL" and "URL", and it worked.
URL: http://jgodse-omniauth-mongoid.heroku.com
Callback URL: http://jgodse-omniauth-mongoid.heroku.com
This is nuts! Twitter wants the trailing slash on the callback but Github does not. Github and twitter should allow both and then trim it automatically if needed.

Resources