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.
Related
I have a "create" action, that gets called by AJAX. This then redirects to another action. On my local machine, everything works fine. Here are the log files from my local machine:
Started POST "/tasks" for 127.0.0.1 at 2016-10-06 20:08:44 +0200
Processing by TasksController#create as JS
Started GET "/roles/refresh_blank_page?cursor=3988&focus=true" for 127.0.0.1 at 2016-10-06 20:08:44 +0200
Processing by RolesController#refresh_blank_page as JS
But on the remote machine, in development or production, it breaks with "ActionController::UnknownFormat". The format suddenly seems to be HTML, as you can see in the log:
Started POST "/tasks" for 88.217.180.75 at 2016-10-06 20:13:00 +0200
Processing by TasksController#create as JS
Started GET "/roles/refresh_blank_page?cursor=3981&focus=true" for 88.217.180.75 at 2016-10-06 20:13:02 +0200
Processing by RolesController#refresh_blank_page as HTML
Here are my actions:
def create
(...)
redirect_to roles_refresh_blank_page_path(focus: true, cursor: #task.id)
end
def refresh_blank_page
(...)
respond_to do |format|
format.js { render :file => "/roles/refresh_blank_page.js.erb" }
end
end
I read many posts here and added "format: 'js'" to the redirect (also tried "remote:true")
redirect_to roles_refresh_blank_page_path(focus: true, cursor: #task.id, format:'js')
In the log I see now:
Started GET "/roles/refresh_blank_page.js?cursor=3983&focus=true" for 88.217.180.75 at 2016-10-06 20:19:12 +0200
Processing by RolesController#refresh_blank_page as JS
But this now produces "ActionController::InvalidCrossOriginRequest in RolesController#refresh_blank_page"
I compared the gems on my local machine and on the remote machine. Some of the gems on the remote machine have higher version numbers. In both cases I'm running rails 4.1.8 and ruby 2.1.5p273.
Thanks for any help,
Ron
I solved this by packaging all my development gems into vendor/cache, using bundle package. Now it works on the remote machine.
cf. Whats the difference between bundle install --deployment and bundle pack
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'
I just launched a production Rails app (on Heroku) on a long-existing domain and, of course, now that it's facing the wide open web, I'm picking up all the flotsam and jetsam of the attempted script kiddies.
I have any exceptions that get thrown emailed to me and I've managed to catch (rescue_from) all the standard errors, but this keeps coming through a few times a day:
An URI::InvalidURIError occurred in #:
bad URI(is not URI?): http://www.myapp.com/assets/,data:n,complete:function(e,t)
{r&&u.each(r,o||[e.responseText,t,e])}}).done(function(e){o=arguments,u
vendor/ruby-1.9.3/lib/ruby/1.9.1/uri/common.rb:176:in `split'
-------------------------------
Request:
-------------------------------
* URL : http://myapp.com/assets/,data:n,complete:function(e,t)
{r&&u.each(r,o||[e.responseText,t,e])}}).done(function(e){o=arguments,u.html(i?v(
* IP address: 195.241.58.105
* Parameters: {"v("=>nil, "path"=>"assets/,data:n,complete:function(e,t){r&&u.each(r,o||
[e.responseText,t,e])}}).done(function(e){o=arguments,u", "format"=>"html(i"}
* Rails root: /app
* Timestamp : 2013-02-26 16:53:51 UTC
So from my untrained eye, this looks like script kiddies attempting to try for some sort of vulnerability (or?)
My questions:
1) This is one area where I'm not sure how far the "rails magic" goes -- do I need to do anything? I don't really like that outside forces are able to cause an exception in my app just from the request. Should I be rescuing the URI::InvalidURIError exception and just throwing a 404? Is there anything more I should be doing? Does this happen to everyone?
2) Is something misconfigured or is this just standard "stock production" behavior for an app? I'm running Rails 3.2.12 (latest patched version as of this posting).
Thanks in advance for any advice!
EDIT: Adding some more details about the requests, as Christian pointed out below, might not be script kiddies? Either way, I'm curious.
2nd request:
An URI::InvalidURIError occurred in #:
bad URI(is not URI?): http://www.myapp.com/assets/&&!yt.test(e)&&
(v.support.htmlSerialize||!wt.test(e))&&
(v.support.leadingWhitespace||!pt.test(e))&&!Nt[(vt
vendor/ruby-1.9.3/lib/ruby/1.9.1/uri/common.rb:176:in `split'
-------------------------------
Request:
-------------------------------
* URL : http://myapp.com/assets/&&!yt.test(e)&&
(v.support.htmlSerialize||!wt.test(e))&&
(v.support.leadingWhitespace||!pt.test(e))&&!Nt[(vt.exec(e)||[
* IP address: 217.16.182.42
* Parameters: {"path"=>"assets/&&!yt.test(e)&&(v.support.htmlSerialize||!wt.test(e))&&
(v.support.leadingWhitespace||!pt.test(e))&&!Nt[(vt", "format"=>"exec(e)||["}
* Rails root: /app
* Timestamp : 2013-02-27 18:37:20 UTC
3rd request:
An URI::InvalidURIError occurred in #:
bad URI(is not URI?): http://www.myapp.com/assets/&&!yt.test(e)&&
(v.support.htmlSerialize||!wt.test(e))&&
(v.support.leadingWhitespace||!pt.test(e))&&!Nt[(vt
vendor/ruby-1.9.3/lib/ruby/1.9.1/uri/common.rb:176:in `split'
-------------------------------
Request:
-------------------------------
* URL : http://myapp.com/assets/&&!yt.test(e)&&
(v.support.htmlSerialize||!wt.test(e))&&
(v.support.leadingWhitespace||!pt.test(e))&&!Nt[(vt.exec(e)||[
* IP address: 62.141.42.107
* Parameters: {"path"=>"assets/&&!yt.test(e)&&(v.support.htmlSerialize||!wt.test(e))&&
(v.support.leadingWhitespace||!pt.test(e))&&!Nt[(vt", "format"=>"exec(e)||["}
* Rails root: /app
* Timestamp : 2013-02-27 20:56:25 UTC
I just found that code in my production.log
GET "/assets/&&!yt.test(e)&&(v.support.htmlSerialize||!wt.test(e))&&(v.support.leadingWhitespace||!pt.test(e))&&!Nt[(vt.exec(e)||["
Rails 3.2.13 dealt with it with Completed 406 Not Acceptable
I found the same in my logs but in november 2012:
ActionController::RoutingError (No route matches [GET] "/assets/&&!yt.test(e)&&(v.support.htmlSerialize||!wt.test(e))&&(v.support.leadingWhitespace||!pt.test(e))&&!Nt[(vt.exec(e)||["):
Here is the error in log file when making initial http connection to the server. It is odd that sometime the server can render a http connection without any problem. But more often with the TZinfo error.
Started GET "/" for 98.206.231.173 at 2011-11-13 09:41:34 +0800
Processing by SessionsController#new as HTML
Rendered sessions/new.html.erb within layouts/sessions (2.2ms)
Completed 200 OK in 4ms (Views: 3.4ms | ActiveRecord: 0.0ms)
TZInfo::InvalidTimezoneIdentifier (no such file to load -- tzinfo/definitions/Etc/UTC):
Any suggestion to fix it? Thanks.
how do you serve your Rails application? Mongrel? Unicorn? ...? can you restart your app, to make sure that all threads have the same config?
Do you have 'tzinfo' listed as a dependency in your Gemfile?
Which version of TZinfo are you using? Can you try to update TZInfo to the latest version?
e.g. run bundle update
all the newer versions of TZInfo, like 0.3.30 , have the directory lib/tzinfo/definitions/Etc with the UTC.rb definition in it as follows:
$ more .rvm/gems/ruby-1.9.2-p0/gems/tzinfo-0.3.30/lib/tzinfo/definitions/Etc/UTC.rb
module TZInfo
module Definitions
module Etc
module UTC
include TimezoneDefinition
timezone 'Etc/UTC' do |tz|
tz.offset :o0, 0, 0, :UTC
end
end
end
end
end
What do you see underneath your .rvm/gems/RUBY-VERSION/gems/ directory? which TZInfo are you using? and is the UTC.rb file there? Are the permissions on the directory and the file 'world readable'?
Maybe it's related to this:
http://rubyglasses.blogspot.com/2008/05/converting-timezone-to-tzinfotimezone.html
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to disable logging of asset pipeline (sprockets) messages in Rails 3.1?
is possible to hack logger in Rails3 to ignore requests for assets?
It is maddness to find something in log, when it is full of
Started GET "/assets/tiscali.png" for 127.0.0.1 at 2011-09-09 19:59:45 +0200
Served asset /tiscali.png - 304 Not Modified (0ms)
Thanks!
I think this could help https://github.com/evrone/quiet_assets
Deprecation
As of sprockets-rails version 3.1.0, used in current versions of rails, this gem is deprecated.
The asset pipeline now supports a quiet option which suppresses output of asset requests:
# config/environments/development.rb
config.assets.quiet = true
Relevant PR: https://github.com/rails/sprockets-rails/pull/355
Info
Quiet Assets turns off the Rails asset pipeline log. This means that it suppresses messages in your development log such as:
Started GET "/assets/application.js" for 127.0.0.1 at 2015-01-28 13:35:34 +0300
Served asset /application.js - 304 Not Modified (8ms)
Support Ruby on Rails >= 3.1...
Usage
Simply installing Quiet Assets will suppress the log messages automatically. However, if you wish to temporarily re-enable the logging of the asset pipeline messages, place the following in your config/application.rb file:
config.quiet_assets = false
If you need to suppress output for other paths you can do so by specifying:
config.quiet_assets_paths << '/silent/'
Apparently the issue is still open as of 02 Nov 2011.
A workaround solution is available in a similar question: How to disable logging of asset pipeline (sprockets) messages in Rails 3.1?
How about an invert selection?
tail -f log/development.log | grep -v asset
This basically outputs everything except for the lines that contain the word "asset".
Rails 3.2:
create a initializer with the content:
Rails::Rack::Logger.class_eval do
def call_with_quiet_assets(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0
call_without_quiet_assets(env).tap do
Rails.logger.level = previous_level
end
end
alias_method_chain :call, :quiet_assets
end
From here: https://github.com/rails/rails/issues/2639