Cached app issue - deployed with capistrano - ruby-on-rails

I have deployed my app for first time. Cap deploy was successful. However I was getting an error on a specific code segment. So I decided to delete this code segment and get the website up and running first before fixing this error.
I run cap deploy again but I am still getting the same error on the code segment that I removed from the source file (I see the error by tailing production.log). It was not suppose to be there. I searched around on the net and found that the problem is that there is a cached version of the app. I found out that a solution would be to delete the cache-copy folder in /shared folder.
I restarted my services (nginx, unicorn) and open the site again and I still get the same error on the code segment I removed.
I checked my new current folder, cached-copy folder and last release folder and all don't have the code segment that produces the error.
It's really odd to me. Any clue whats going on?
Thanks!
Code segment that produces the error:
ActionView::Template::Error (undefined method `stripe' for #<Rails::Application::Configuration:0x00000002a85578>):
20: <meta name="viewport" content="width=device-width">
21: <%= javascript_include_tag 'application' %>
22: <%= javascript_include_tag "https://js.stripe.com/v1/", type: 'text/javascript' %>
23: <%= javascript_tag "Stripe.publishableKey = '#{Rails.configuration.stripe[:publishable_key]}';", type: 'text/javascript' %>
24: <%= csrf_meta_tag %>
25: <%= stylesheet_link_tag "application", :media => "all" %>
26: <script type="text/javascript" src="//use.typekit.net/xoh2pss.js"></script>
app/views/layouts/application.html.erb:23:in `_app_views_layouts_application_html_erb__486989174473553269_34754060'
The line 23 was removed but its still shown as generating the error.

# config/initializers/stripe.rb
Stripe::API_KEY = 'asd8df9sadf766'
# application.html.erb
<%= javascript_tag do -%>
Stripe.publishableKey = <%= Stripe::API_KEY %>;
<% end -%>

Are your assets precompiled and the old all.js (or similar) being redeployed without this change present? If the routine invoked by the javascript portion isn't present that could produce an error -- that might be the stripe method you're trying to invoke. If they were manually precompiled and you made the change but didn't re-compile it, the redeploy would simply put the old one back out there.

Related

parse error in ruby routes

I am launching my first ruby server i have launched the server to view the welcome aboard page and have generated a controller for the page however when i change the route file and uncomment the following statement
root 'welcome#index'
I get the following error
JSON::ParserError in Welcome#index
Showing C:/Sites/examplesite/app/views/layouts/application.html.erb
where line #5 raised:
757: unexpected token at 'Script execution time was exceeded on script
"AppData\Local\Temp\execjs20160617-1504-n6adzfjs".
Script execution was terminated.
'
Rails.root: C:/Sites/examplesite
what part of the code is causing the error and how can it be fixed
these are the code which is run
index.html.erb
<h1>Hello, Rails!</h1>
routes.rb
Rails.application.routes.draw do
get 'welcome/index'
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
root 'welcome#index'
#root 'welcome#index'
application.html.erb (where the error is reported on line 5)
<!DOCTYPE html>
<html>
<head>
<title>Examplesite</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>
Is this producing on other machines too?
This message is issued if the systems cscript timeout period is exceeded before a script completes execution.
Any program that uses the cscript command in Windows has the ability to add a /s switch in addition to the /t timeout command.
When the /s switch is used, all of the switches from the command (which includes the /t timeout) are saved to the registry.
Vivado does not use the /s switch.
However, the cscript commands that are issued from Vivado are subject to the settings saved by another program.
To fix this, go to the following location in the registry (regedit), and delete the "Timeout" key, or set it to 0:
HKEY_CURRENT_USER\Software\Microsoft\Windows Script Host\Settings

Rails leaflet map geosearch stopped working after precompiling assets

I'm using meijer's geosearch in a leaflet map. It was working fine but I've suddenly broken it and I don't know how. The maps still appears, but the search box doen't appear in the map. The code that breaks the app is (leaflet_map.js):
new L.Control.GeoSearch({
provider: new L.GeoSearch.Provider.OpenStreetMap(),
showMarker: false,
position: 'topright',
retainZoomLevel: false
}).addTo(map);
I don't think it can find the geosearch js or css files, even though I've clearly included them in application.html.erb:
<%= stylesheet_link_tag "leaflet.css" %>
<%= javascript_include_tag "leaflet.js" %>
<%= stylesheet_link_tag "l.geosearch.css" %>
<%= javascript_include_tag "l.control.geosearch.js" %>
<%= javascript_include_tag "l.geosearch.provider.openstreetmap.js" %>
I think the turning point might have been when I typed bundle exec rake assets:precompile at the command line (I also did RAILS_ENV=production bundle exec rake assets:precompile). Why would that break geosearch?
I have deleted my public/assets folder, but that didn't make any difference.
Also, the console doesn't show any complaints about broken geosearch.js files or not finding them. I am, as usual, baffled.
js console:
Uncaught Error: Map container not found.
Uncaught TypeError: Cannot read property 'Provider' of undefined
Mixed Content: The page at 'xxxx' was loaded over HTTPS, but requested an insecure image 'http://a.tile.openstreetmap.org/13/7424/5131.png'. This content should also be served over HTTPS.
view:
<div id="map-leaflet"></div>
<%= javascript_include_tag "easy-button" %>
<%= javascript_include_tag "leaflet_map" %>
leaflet_map.js
map = L.map('map-leaflet', {center: [10.0, 10.0], zoom: 16} );
map.options.maxZoom = 22;
L.tileLayer(
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox',
maxZoom: 22
}).addTo(map);
// add location search box
new L.Control.GeoSearch({
provider: new L.GeoSearch.Provider.OpenStreetMap(),
showMarker: false,
position: 'topright',
retainZoomLevel: false
}).addTo(map);
Demo site here
Your leaflet-map init code is being included twice, once inside <script src="/assets/leaflet_map-8e1007491534b1245e2ccc867a845d14e60679a58ca180c5e9cbef68530aa571.js"></script>and once from application.js. Drop the leaflet-map asset reference underneath your map div to begin working through these problems.

Content for doesn't work in production mode

On one of application's page there is:
<% content_for :head do %>
<%= tag :meta, property: "fb:app_id", content: ENV["FACEBOOK_APP_ID"] %>
<% content_for :title, #check.title %>
<% end %>
And it worked in development, while I was running server at my localhost.
After that I deployed application on heroku. And that simply doesn't work.
What means doesn't work. I load page in development at localhost:
<title>Tenta</title>
<meta content="*****************" property="fb:app_id">
When I load this page deployed at heroku host, these tags are simply absent.
Why?
Also, If you don't know this particular issue solution, I would appreciate if you adivce me, how can I look what is going on - heroku logs and watching last 150 logs in inconvinient windows console doesn't give me a lot of helpful information.

Rails Error hitting the url on server start: ExecJS::RuntimeError in Spree/home#index

I am trying to setup code on mac os. it worked perfectly on ubuntu. i installed all the gems and when i hit the url after switching on the server i am getting this error. deeply frustrated
Showing /Users/ayruskrishna/code/krizda/app/views/spree/shared/_header.html.erb where line #13 raised:
FATAL ERROR: CodeRange::GetNextAllocationBlock Allocation failed - process out of memory
(in /Users/ayruskrishna/.rvm/gems/ruby-1.9.3-p385/gems/spree_core-1.2.0/app/assets/javascripts/store/checkout.js.coffee)
Extracted source (around line #13):
10: <%= favicon_link_tag '/assets/favicon1.ico' %>
11: <%= stylesheet_link_tag 'store/all', :media => 'screen' %>
12: <%= csrf_meta_tags %>
13: <%= javascript_include_tag 'store/all' %>
14: </head>
15: <body>
16: <div class="wrap">
Trace of template inclusion: app/views/layouts/spree.html.erb
Rails.root: /Users/ayruskrishna/code/krizda
It appears you're using Spree 1.2.0 I'd suggest trying a newer version (v1.2.4 is available in the same stable line). I'd also checkout the Activity Monitor OS X app.. A spree store for me typically uses less than 200MB of RAM.
You could also look at using an alternative web server... http://puma.io/ claims to have a significantly smaller memory footprint than some of the alternatives.

token_error on heroku when I try to load Google API

I am using winston/google_visualr to create nice graphs to visualize statistics in my rails application.
It works fine on my locale system, but if I push it to heroku I get something like a token_error. The result is, that it shows only the Heroku page
We're sorry, but something went wrong.
My head section of application.html.erb looks like this
<head>
<title><%= full_title(yield(:title)) %></title>
<script src='http://www.google.com/jsapi'></script>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
This is the heroku log:
ActionView::Template::Error (Unexpected token name, expected punc (line: 13588, col: 3, pos: 384041)
at expect (/tmp/execjs20121119-2-qx6eku.js:977:40)
Error
at js_error (/tmp/execjs20121119-2-qx6eku.js:505:15)
at new JS_Parse_Error (/tmp/execjs20121119-2-qx6eku.js:497:22)
at token_error (/tmp/execjs20121119-2-qx6eku.js:961:17)
at expect_token (/tmp/execjs20121119-2-qx6eku.js:974:17)
at object_ (/tmp/execjs20121119-2-qx6eku.js:1365:56)
at /tmp/execjs20121119-2-qx6eku.js:1326:51
Completed 500 Internal Server Error in 4980ms
at croak (/tmp/execjs20121119-2-qx6eku.js:954:17)
at maybe_unary (/tmp/execjs20121119-2-qx6eku.js:1425:27)
at expr_ops (/tmp/execjs20121119-2-qx6eku.js:1452:32)
(in /app/app/assets/javascripts/application.js)):
6: <%= stylesheet_link_tag "application", :media => "all" %>
7: <%= javascript_include_tag "application" %>
8: <%= csrf_meta_tags %>
9: <%= render 'layouts/shim' %>
4: <title><%= full_title(yield(:title)) %></title>
5: <script src='http://www.google.com/jsapi'></script>
app/views/layouts/application.html.erb:7:in `_app_views_layouts_application_html_erb__1437494530852335371_34567960'
It looks like that the external script reference may be the reason. Do you have any idea how to implement this?
The demo implementation of the author of the googlevisualr rails extension on heroku works fine. Is there any configuration settings in heroku I need to consider?
Thanks for your help.
It took me a lot of tries but I found the issue.
The error happens if one of the included JS' has syntax errors, i.e. a missing semicolon.
In my Gemfile I didn't add version numbers to my gem '...'.
I was using the gem 'bootstrap-datepicker-rails' in version '0.6.21' for my development environment.
If you push to heroku all your gems will be installed again, with the newest available version. Since version 0.6.28 is the actual version it was installed on heroku. It may have a syntax error and it caused the above issue. So, it had nothing to do with the line
<script src='http://www.google.com/jsapi'></script>
I just corrected the line in my gemfile to the following and all was working then:
gem 'bootstrap-datepicker-rails', '0.6.21'

Resources