I created a rails app using the HighCharts gem and an external API to seed the db. Everything works perfectly on my local server but when I deployed to Heroku (using postgreSQL) and running all the heroku run rake db:migrate, db:seed commands, my chart does not load.
I get the following error in my console:
Mixed Content: The page at 'https://myappname.herokuapp.com/' was loaded over HTTPS, but requested an insecure stylesheet 'http://fonts.googleapis.com/css?family=Signika:400,700'. This request has been blocked; the content must be served over HTTPS.
I am using a theme which I require in my application.js file that uses googlefonts via HTTP (NOT HTTPS) and I think I need to change this to //fonts.google... but I don't know how since I'm using the gem.
When I tell my browser (Chrome) to display the insecure scripts, the chart still does not appear and the console spits out an empty array which tells me my data is not in Heroku.
Please let me know what other info I can provide. As you can see I think I have 2 issues.
Thank you!
With the help of the HighCharts Rails gem folks, I was able to manually download the source code and change the pertinent parts to be protocol independent. All it required was copying the theme.js code into app/assets/javascripts, make the changes, and load that file instead of //= require highcharts/themes/sand-signika in my application.js.
Am still having an issue with data not migrating from my local db to Heroku...
Related
I'm trying to use ahoy_matey gem in development env. i.e. Windows7 64 bit and rails 4.0.9 by following the doc at https://github.com/ankane/ahoy.
I would like to use this gem to track user visits and ip addresses in particular and then restrict the number of sign-in's per IP address. I've followed the readme file but unable to see records in visits table in my pg db.
Below are the steps I've followed so far -
gem 'ahoy_matey' #included in gem file and ran bundle install
//= require ahoy # included this line in application.js file
rails generate ahoy:stores:active_record -d postgresql
rake db:migrate
gem 'fluent-logger' #ran bundle install after including this line in gem file
The below command generated an error- Could not find generator ahoy:stores:fluentd.
rails generate ahoy:stores:fluentd
I've tried including below script in /layout/application.html.erb and other pages as well inside script tags without success.
ahoy.trackAll();
included the below in my sign in method in session controller
ahoy.authenticate(user)
Included the below in my index method of landing page without success.
ahoy.track "Viewed Landing", title: "Landing page viewed"
The only thing that has worked so far is below code which I've added in my application controller and it is populating my ahoy_events table.
class ApplicationController < ActionController::Base
after_filter :track_action
def track_action
ahoy.track "Processed #{controller_name}##{action_name}", request.filtered_parameters
end
I've also restarted my rails webserver (I'm using thin in dev and puma in prod).
Could you please let me know what I'm missing here. What do I need to do differently with my ahoy setup to enable it to start writing records to the "visits table" in my pg database.
Any pointers will be appreciated.
TIA
have you try to find some js code that may not be compliant with browsers that doesn't appear in visits table ?
edit :
I detail my idea : if you have any js code not compliant that make browser didn't get 200 http success and then the page loading fail, if your ahoy call is after that, browser didn't execute it
I am using Heroku to try to deploy a personal Ruby on Rails project and everything was going great until today.
I am very very new to Ruby on Rails and Heroku so please bare that in mind. I am not sure what is causing my issue and therefore not sure what code or information is best to supply so please ask me what you think you need to know to help resolve the issue and I will provide it.
My Ruby on Rails app worked fine both locally and on Heroku until I followed the information here to try and serve static images from Amazons S3 bucket. Note I only went as far as the static assets section.
This appeared to stop my Ruby on Rails application from recognising changes in my code. So I would make a change to a HTML file in my editor but the server was serving up the older version of the HTML file, even restarting the server didn't fix this.
I have been searching the web for hours trying to figure out what has gone wrong.
I deleted everything under public assets and I ran the precompile command:
rake assets:precompile
And this seems to have improved things locally, when I edit a HTML file the changes are reflected on localhost. However when I push to Heroku and go to my application hosted on Heroku it still shows the older HTML file no matter how many changes I make and pushes I do to Heroku.
The HTML files that are not updating are located here:
app/assets/templates
I'm not sure what I may have changed that has caused the HTML files not to get updated on Heroku?? What should I look at and try? What other information would be useful in helping track down the issue?
The answer marked as correct in this StackOverflow question worked for me - Updated CSS Stylesheet not loaded following deployment to Heroku? - It looks like I accidently added assets precompiled file in my git repo somewhere along my development and that caused the issue.
I'm trying to add media query changes to a rails site built with foundation. The server is apache and phusion. However when I make changes to the stylesheet nothing changes on the site.
After I save the changes I'm also doing
touch tmp/restart.txt
in termial and still nothing changes. I imagine it has something to do with rails production. Any way to overwrite this?
Double-check to make sure that your browser hasn't cached everything. So either empty the cache or try a different browser.
If that doesn't work, try running rake assets:clean before each push (whenever you've precompiled locally).
parse: (response, options) =>
#totalRecords = parseInt(response.result_count)
#totalPages = Math.ceil(#totalRecords / #perPage)
response.data
Works perfectly on local dev env, local production env. But when deployed to production, the parse function can't get any data back(it was even not triggerd).
Played in the browser console, use collection.fetch(), it has response, but just can't pass it into my collection.
Sounds like it is not a code problem so much as a deployment issue. If you can get production working locally, this should mean your code works.
Could the problem be either the assets are not precompiled when they are needed (or not updated on the production server). Remember with Heroku and some providers you need to push the precompiled assets when you deploy or ensure they get build on the server.
Thanks to #bodacious I was able to solve this. It's a server side thing. For nginx+unicorn case, just add
proxy_buffering off
to your location block in nginx.conf, and everything works again!
References here: Incomplete response body being returned from Rails 3 app with RABL
Thank you all!
Following the Railscast episode on copycopter, so I set up my copycopter server on heroku. Everything works great, until AWS goes down and brings down heroku. At that moment, all my copycopter text reverted to the default text I had entered on my html pages.
Is there a way I can store the results from a successful call to my copycopter server on my rails server so that, in case of another heroku outage, my text will still be from copycopter?
Could you use I18n cache by passing a cache store or even I18n memoization? In my Rails app, I have I18n::Backend::Simple.include(I18n::Backend::Memoize) in an initializer, so all the translations are cached in memory after the first hit.
I18n also supports using a real cache store so you could use memcached or redis to store the copies which would avoid the issue you mentioned when copycopter server goes down.
From copycopter readme, you can also export the blurbs:
Blurbs are cached in-memory while your Rails application is running. To export all cached blurbs to a yml file for offline access, use the rake task:
rake copycopter:export
The exported yaml will be located at config/locales/copycopter.yml.