TZInfo::InvalidTimezoneIdentifier with rails 3.1.0 and ubuntu - ruby-on-rails

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

Related

webpacker compiling but not saving file in dev

I am working on a project using rails and react Am using webpacker. I get this message:
Processing by CurrenciesController#index as HTML
Rendering currencies/index.html.erb within layouts/application
[Webpacker] Compiling…
[Webpacker] Compiled all packs in C:/Users/omokehinde/Documents/RailsProjects/cryptoCalculator/public/packs
Rendered currencies/index.html.erb within layouts/application (9526.0ms)
Completed 500 Internal Server Error in 9955ms (ActiveRecord: 0.0ms)
ActionView::Template::Error (Webpacker can't find hello_react.js in C:/Users/omokehinde/Documents/RailsProjects/cryptoCalculator/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
unless you are using the webpack -w or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:
{
}
):
1: <%= javascript_pack_tag 'hello_react' %>
app/views/currencies/index.html.erb:1:in `_app_views_currencies_index_html_erb___1553736711_70532840'
the compiled file isn't saving and the packs folder isnt created.
here is a link to the repo on github: https://github.com/omokehinde/cryptoCalculator
please help!

redirect_to after AJAX post stops working on remote machine

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

Ruby on Rails, image compilation and precompilation

I just deployed a rails app and I am having an error when I load a page saying:
We're sorry, but something went wrong.
In the production.log I see that message:
Started GET "/" for 128.179.252.130 at 2014-11-30 08:32:28 +0000
Processing by StaticPagesController#home as HTML
Rendered static_pages/home.html.erb within layouts/application (0.4ms)
Rendered layouts/_shim.html.erb (0.0ms)
Rendered layouts/_header.html.erb (2.4ms)
Completed 500 Internal Server Error in 4ms
ActionView::Template::Error (./icons/icon_nameplate.png isn't precompiled):
37:<ul class="dropdown-menu">
38:
39:<li>
40: <%= menu_dropdown('Profile', "./icons/icon_nameplate.png", "Nameplate Icon", current_user) %>
41:</li>
So I believe the error comes from this part of the message:
./icons/icon_nameplate.png isn't precompiled
I searched the internet, found three possible solution, none of which did work:
1. config.assets.compile = true (in production.rb file)
2. config.assets.precompile += %w[*.png *.jpg *.jpeg *.gif] (still in production.rb file)
3. bundle exec rake assets:precompile RAILS_ENV=production
All of this changed absolutely nothing, and the website still shows the same error. So I am turning for you to help.
Thank you very much in advance.
What finally did the trick for me is completely restart the rails app. This is described in the link below.
The recommended version did the trick for me which is:
Create (or update) a file called restart.txt in the tmp folder of your Rails application on the server.
After that no problem at all.
Cheers

Windows - JRuby on Rails - ActionView::Template::Error invalid encoding

I want to try jruby 1.7.0.RC2 on Windows with Rails 3.2. I'm able to start the server, but each time I try to access a page that requires a css (javascript_include_tag), I get the following error:
invalid encoding in marshaling stream: I"co
Here is the stack trace, if it helps:
ActionView::Template::Error (invalid encoding in marshaling stream: I"â—„co):
9: = stylesheet_link_tag "application", :media => "all"
app/views/layouts/application.html.haml:9:in `_app_views_layouts_application_h
tml_haml__357561048_13162'
Rendered C:/jruby-1.7.0.RC2/lib/ruby/gems/shared/gems/actionpack-3.2.8/lib/act
ion_dispatch/middleware/templates/rescues/_trace.erb (7.0ms)
Rendered C:/jruby-1.7.0.RC2/lib/ruby/gems/shared/gems/actionpack-3.2.8/lib/act
ion_dispatch/middleware/templates/rescues/_request_and_response.erb (6.0ms)
Rendered C:/jruby-1.7.0.RC2/lib/ruby/gems/shared/gems/actionpack-3.2.8/lib/act
ion_dispatch/middleware/templates/rescues/template_error.erb within rescues/layo
ut (41.0ms)
My application.css is only the result of the default asset pipeline, nothing fancy. I even get the same error with an empty application.css.scss file...
Everything works fine with Ruby MRI 1.9.2 and 1.9.3.
I must say that when it comes to encoding, I'm clueless. Any idea?
Running rake tmp:clear in the project root dir fixed this issue for me. It seems that jRuby does not like to use MRI Ruby's cached files.

Heroku: see params and sql activity in logs?

When i view my heroku logs on the server (with heroku logs --tail --app myapp) i see something like this:
2011-06-21T14:09:25+00:00 app[web.1]: Started PUT "/reports/19.xml" for 77.89.149.137 at 2011-06-21 07:09:25 -0700
2011-06-21T14:09:25+00:00 heroku[router]: PUT myapp.heroku.com/reports/19.xml dyno=web.1 queue=0 wait=0ms service=7ms status=401 bytes=28
2011-06-21T14:09:26+00:00 heroku[nginx]: PUT /reports/19.xml HTTP/1.1 | 77.89.149.137 | 656 | http | 401
While in my local log i'd see something like this:
Started PUT "/reports/19" for 127.0.0.1 at 2011-06-21 15:27:01 +0100
Processing by ReportsController#update as XML
Parameters: {"report"=>{"workflow_status"=>"3"}, "id"=>"19"}
Person Load (0.9ms) SELECT "people".* FROM "people" WHERE "people"."email" = 'madeupemai#lkklj.com' LIMIT 1
Report Load (0.4ms) SELECT "reports".* FROM "reports" WHERE "reports"."id" = 19 LIMIT 1
DEPRECATION WARNING: Object#returning has been deprecated in favor of Object#tap. (called from update_report at /home/max/work/rails_apps/flamingo_container/flamingo/vendor/plugins/resource_this/lib/resource_this.rb:135)
Creating scope :open. Overwriting existing method Task.open.
Task Load (2.0ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."id" = 14 LIMIT 1
Completed 200 OK in 1648ms (Views: 568.2ms | ActiveRecord: 3.2ms)
Ie with a lot more information, particularly the params, info from the router, generated sql, any templates rendered etc etc.
Does anyone know how i can get my heroku log to be as verbose as my development one? I've done the following already:
1) Set the log level in the relevant (rails 3) environment file:
config.log_level = :debug
2) Told heroku to use a different logger level, as described on http://devcenter.heroku.com/articles/logging
heroku config:add LOG_LEVEL=DEBUG --app myapp #from CLI
Neither has made any difference...any ideas anyone?
thanks, max
You're essentially wanting to show the SQL / params output in the Heroku logs. You can do this by adding the line shown below to the config block within your production.rb file:
MyAppNameHere::Application.configure do
# add this line
config.logger = Logger.new(STDOUT)
end
By the way, setting the log level to debug just means that Rails.logger.debug will output to the logs when you're on Heroku
In your production.rb add config.log_level = :debug and redeploy. That will give you the same logs as development mode :)
The detailed log you want is generated by the function start_processing in log_subscriber.rb.
action_controller/log_subscriber.rb:
def start_processing(event)
payload = event.payload
params = payload[:params].except(*INTERNAL_PARAMS)
info " Processing by #{payload[:controller]}##{payload[:action]} as #{payload[:formats].first.to_s.upcase}"
info " Parameters: #{params.inspect}" unless params.empty?
end
I checked with rails 3.0.4 in development and production environment. In both environments, we have the detailed logs.
This is an info level log. That's why the debug log level is not changing the output.
I installed the plugin used by heroku rails_log_stdout (Heroku logging) but I still have the desired output.
Right now, I can't test with heroku to find out why you don't have all the logs.
In the heroku example (see Heroku logging, section log retrieval), we don't see the "Processing" and "Parameters" lines. I think that either this method is not called when the app is running on heroku (it is somehow disabled) or heroku skips logs starting with whitespaces. Could you try to log messages starting with whitespaces and see if heroku is showing them?
Rails doesn't generate those logs when in production mode. http://groups.google.com/group/heroku/browse_thread/thread/d778fafedc9a378a
The real problem is actually due to the way Heroku works in conjunction with rails. The right way to solve this is to add: gem 'rails_12factor', group: :production
See https://devcenter.heroku.com/articles/rails-integration-gems for more info on the matter
Looks like the puma server doesn't play well with Heroku. In my project, I tried everything, but it still wouldn't log. I then replaced Puma with Unicorn, and bam, full logs are being shown.

Resources