I am relatively new to web dev and I am trying to set up the ruby on rails gem ga_events (https://github.com/Nix-wie-weg/ga_events). I am doing this because I need to have google analytics event tracking within controllers and this gem seems like a good way to do it. The issue I am having is where the readme says, "After requiring ga_events.js, you have to choose an adapter." I am using Google Universal Analytics and thus I would like to choose that one. It doesn't say specifically how to do this. Where do I put that code block (https://github.com/Nix-wie-weg/ga_events#google-universal-analytics-analyticsjs)? Do I need to make a new file somewhere?
I'm assuming it's obvious for a more experienced developer. More detailed instructions+explanation would be really helpful. Thanks.
I'm using Rails 4.0.13 and Ruby 2.0.0p643.
I was having the same issue here! Turns out, it is just javascript code.
I put mine under application.js since it's a code that need to be on every page.
Related
Thanks for your help,
I believe this is very simple but I can't figure it out. Following the instructions at https://github.com/darkskyapp/forecast-ruby - it tells me to not forget to add require 'forecast_io' - what file do I put this in?
I've run a scaffold to set up a simple lat and lng, following this guide:
https://campushippo.com/lessons/an-easy-way-to-implement-weather-forecasting-in-rails-9d10403 but keep on getting method errors. So I think we are using different versions of Ruby & Rails, and/or I'm placing this code in the wrong file, or wrong place. My question isn't about method errors, but just where to place this.
I'm unsure whether or not to place it in /config/application.rb; create and place the code in /config/forecast_io.rb; or to create and place it in /config/initializers/forecast_io.rb; or if it's supposed to go somewhere else entirely.
I've looked at the api docs, the ruby wrapper read me, and also have read other tutorials (they won't let me post more links, otherwise I would list them) - one is from hackpsu.westarate that is kind of different with using sinatra, went through the Treehouse tutorial on Rails scaffolding, and began their tutorial on creating an API to better understand REST, and have looked at other rails projects to see how they incorporate external API's, so I'm in the thick of it, and am banging my head against the wall because it seems so simple, but I'm not seeing it yet.
Thanks for your help!
David
In Rails, placing a gem in your Gemfile already requires the gem by default, unless explicitly stated to ignore.
If you're still bothered about it though, you could add the require option to your gem as such:
gem 'forecast_io', require: 'forecast_io'
Now, for the rest of the configurations mentioned, you can create a file in your initializers and the following:
#config/initializers/forecast_io.rb
ForecastIO.configure do |configuration|
configuration.api_key = 'this-is-your-api-key'
end
I am looking for an open source web analytic for my Rails 4.2 app, so after some research I found that piwik fit my needs. can I use "piwik" with postgresql ? it seems that they only support mysql but I am not sure if it still true at this moment!
also I've found a post about how to integrate it within Rails here but they use piwik_analytics which is a Gem for Ruby on Rails 3.x and may not work with 4.2 !
All the information I've found are a little outdated and I am not sure if there is a way to make it work with my current requirements. any help please ?
Piwik supports only MySQL, that's true
You don't need any gem because Piwik just needs to load some Javascript that needs to be embedded into your layout/views. The Rails app doesn't directly interact with it, only your visitors' browser. Which also means that it shouldn't matter whether it supports Postgres because it will most likely run on another machine as your Rails app.
Edit:
Regarding the gem you mentioned: I looked at it, too, when adding Piwik analytics to my app, but in the end went with writing the few required lines of JS myself.
I'm working on a government transparency app. For the app I'm using two different APIs from the sunlight foundation. One already had a good gem wrapper that provided all the functionality I needed. The other didn't, so I wrote the code myself with the plan of packaging it as a gem and using it in my app. The code is done, but needs some refactoring as well some setup to properly turn it into a gem. Unfortunately, I need to finish the app quickly for a demo I'm doing in a couple of days and just want to add the code to my existing app for the moment and then extract it out later to make a gem.
I'm a new programmer(about 3 months), so I'm still getting some of the convention and what not. What I'm not sure is where to put the code in my rails app. Does it go in the model, controller, or do I build a separate helper module. The code for the app is here: https://github.com/gbcosgrove/sunlight-influence. It consists of an API call constructor and then separate files for each category. I'm still in the process of refactoring because I find it easier to just write code that works and then go back and iterate until its clean.
Any insight on where to put this code in an existing rails app not as a gem would be awesome. Thank you so much!!
A few months ago there was a feature in the Rails API documentation that let you visit the a Rails source file on Github by clicking "on Github". Ryan Bates even tweeted about it. This was a great feature because you could easily explore the source for the entire file instead of just for a single method.
Does anyone know what happened to this feature?
I believe they removed them when they started using Ajax for the show. This happened when they switched to sdoc. Perhaps its an sdoc limitation, as everyone seemed to enjoy it.
I would recommend posting on the google group and get a discussion going requesting more information and/or getting them back.
You can find the group here.
Rails documentation generated from using the standard Rdoc Rake task provided with the rails source still produces this extra link to github.
There's still a flag for it in the rakefile.
Whatever or whoever generates the documentation for the API must be omitting this flag.
It looks like the github links are back as of Rails 3.2.0!
I am creating a simple facebook application using Ruby on rails and I am following the liveRail tutorial available here
http://www.liverail.net/articles/2007/6/29/tutorial-on-developing-a-facebook-platform-application-with-ruby-on-rails
The problem that Im facing is that when I launch my server it throws an error saying that it cant find the 'gem_original_require' : no such file to load facebook_rails_controller_extensions.
I have added the rfacebook gem but the error is thrown when i include the require
require "facebook_rails_controller_extensions" in the environment.rb file.
Im not completely sure whether this is the right way to go with Rails 2 but I've between making changes when i find relevant information for Rails 2
I would appreciate any suggestions on this or any links to other tutorials too.
Thank you
That tutorial is SEVERELY out-of-date and you're going to have lots of issues if you keep following it. rFacebook hasn't be actively maintained in a good 2 years. You should be using Facebooker.
There is a good facebooker tutorial here: http://apps.facebook.com/facebooker_tutorial/
Examine your $LOAD_PATH variable.
It's a common issue that your load path doesn't contain library.
Use $LOAD_PATH<<'/usr/lib/superrubylib' to add a path to load.
Uh, and it seems to be a best practice to use require File.dirname(__FILE__) + "/../relative/path" to set up relative paths.
P.S. Please, specify more data about paths and locations to let us answer your question specifically.