I'm using the gem rack-google-analytics in my rails project but when I run it in production mode I get an error.
rack-google-analytics-0.11.0/lib/rack/google-analytics.rb:11:in `initialize': Tracker must be set! (ArgumentError)
I'm trying to find out what this means. initialize': Tracker must be set!
in my application.rb file I have this at the bottom of it.
if Rails.env == "production"
config.middleware.use("Rack::GoogleAnalytics", :web_property_id => "UA-18760745-1")
end
If O take that out the error goes away so it has something to do with initializing this behavior, but just not quite sure why.
Anyone ran into this issue and have a solution to it, that they could share.
The only answer I could find was to not use that Gem and use this one instead as it works right out of the box. Maybe someone else can prove me wrong, which I hope.
Hope this other link helps someone else.
https://github.com/bgarret/google-analytics-rails#readme
Don't know if it helps, but here is my code:
config.middleware.use Rack::GoogleAnalytics, :tracker => 'UA-XXXXXXXX-1'
in application.rb
I'm assuming it requires a value for the :tracker symbol upon initialization (I'm following this readme on the gem's GitHub: https://github.com/kangguru/rack-google-analytics)
Obviously, replace XXXXXXXXX with your organization's tracker code.
And it seems like setting the :web_property_id symbol is a feature of a different (but similarly named) gem, rack-google_analytics: https://github.com/ambethia/rack-google_analytics
Related
First, thank you for take your time reading my question!
The problem is that when I try to start my system, the repl can't find some files, but if I go and load manually, each of this file's dependencies one by one before it, the file loads perfectly.
Example of manual loading:
The commands I'm trying to execute:
(clojure.tools.namespace.repl/refresh)
Getting this error:
:via [{:type clojure.lang.Compiler$CompilerException,
:message "Syntax error compiling at (purchase_listinator/adapters/db/purchase_category.clj:1:1).",
:data #:clojure.error{:phase :compile-syntax-check,
:line 1,
:column 1,
:source "purchase_listinator/adapters/db/purchase_category.clj"}
I also tried this one:
(do (require '[com.stuartsierra.component.repl :as crepl])
(require 'purchase-listinator.core)
(crepl/reset))
Getting this error:
Syntax error compiling at (purchase_listinator\core.clj:1:1).
namespace 'purchase-listinator.components.pedestal' not found after loading '/purchase_listinator/components/pedestal'
Repository at the moment of this error for future reference
I have no idea what is happening, actually, I've been working on this project for many time and it was working well until this week.
I tried to research, but I had no success, it should be a simple thing that I'm missing, but I can't see it. I would be glad if you help me with this. Thank you so much in advance :)
(Maybe)Removing the .idea folder and reopen the project helps.
First, the problem is not related to the repository itself.
I have no idea what is happening, but I just clone the repository in another folder and I tried to start the system again, and guess what? It worked...
Probably there is a strange thing happening in my local folder, but I don't know what :/
Thank you so much!
I'm starting up with Backburner to run some jobs in the background of my app. I've tried following the documentation under "Working Jobs", but I'm clearly doing something very obvious and very incorrect.
Gemfile:
gem 'backburner'
Rakefile:
require_relative 'config/application'
require 'backburner/tasks'
Rails.application.load_tasks
And then in the rails console:
rake backburner:work
(which I think will just run all pending, enqueued backburner jobs.)
But all I get is the error: NameError: undefined local variable or method 'work' for main:Object from (pry):1:in '__pry__'
I sorta know what pry does (I use it to throw binding.pry into my code to debug, but that's about it), but I have no idea how it might be causing this. Not to mention I'm still pretty weak on the whole jobs and rake task front in general.
Any help would be much appreciated!
Apparently I'm in the business of asking dumb questions, lately. I was passing a variable to my Backburner.enqueue that is an ID, so I expected it to be numerical, like so: #admin.id. This would have been fine if #admin was defined in the scope of the helper I'm calling my enqueue in, but I'm actually passing that variable to that helper method...which means #admin is not defined, which, guess what Daniel, means #admin.id is undefined. Which means that I'm hitting the job anyways (because no, Backburner is in fact NOT breaking), but I'm not getting the job enqueued the way I thought I was because I was passing an invalid property to it.
So it sort of turns out that the error I got looked completely unrelated to the issue, but there it is. Always pass the variables your methods are expecting, or else expect errors.
EDIT:
Also, I can't downvote my own post. I tried. It deserves it.
EDIT 2:
Turns out it's really hard/not supported to get beanstalkd going on Heroku. Der. Also should have checked that. I just liked how beanstalkd was handling some things and went with it before getting to deploy and realizing it was a no-go.
Instead, I went with Resque as suggested by Heroku. They also support Delayed Job (DJ), but noted it is pretty heavy and Resque is better.
All that to say, I finally got to where I needed to go with Resque, and because it was such a thing I made a little documentation to help me (and maybe any other sad soul who stumbles across this lame post) get background workers running on a Heroku-hosted Rails app in the future. Be warned: it really is a guide for dummies like me, since I had to puzzle out a lot of what now is fairly obvious to me. There are gaps in the Resque documentation that I've included, which really just boils down to being explicit about what certain things mean, and where things go.
I working with medium Rails application which has about 60 gems dependencies. Many of these dependencies are unnecessary/useless.
Is there any way to find out which gems are not used by application?
This is not possible.
You could however start with the following:
1) Go to http://rubygems.org/ and search for gems, you think aren't 'available' anymore. If they're removed from rubygems, You can't use them anymore so Delete them from your gemfile.
2) Just look carefully into your app and just write down which ones you're sure about. The ones you aren't sure about are the ones you don't use.
3) You can use this: http://ruby-prof.rubyforge.org/ to show the called parameters, call times, memory usage and object allocations
Hope it helps you :)
I have a feeling this is a dumb one, but I've spent some time trying to figure it out and googling it, and to no avail. I'm trying to use a Ruby Gem in a Controller. I have included it in my Gemfile, run bundle install, seen it show up in my gems list, restarted my local server. But somehow whenever I try to call the gem ( rails_rrdtool ) It just tells me
uninitialized constant RrdgraphsController::RRD
app/controllers/rrdgraphs_controller.rb:22:in `show'
The spot in my code where it wigs is when I'm calling
RRD.graph
It's as though it doesn't know where the heck the gem is... However, I can use require to import it successfully into an irb session. So I know that it works, it's just not getting in there some how...
Bundler should be handling the inclusion of the gem I assume. Am I calling it in the wrong place?
This looks like a namespacing issue. Your error says it is looking for the constant inside of the current class: RrdgraphsController::RRD when it should be looking for a class outside of the current context.
Try prefixing the class name with a double colon to fully define the location of the class.
::RRD.graph #rest of your code
There's a good analogy of what this does in this other accepted answer. Basically it creates an absolute path so Ruby doesn't have to guess.
Got an error
uninitialized constant Formtastic::FormBuilder(NameError)
And this, in my config/initializers/client_side_validations.rb
require 'client_side_validations/formtastic' if defined?(::Firntastic)
#seems like comment this line out will fix the problem
#but I need Formtastic here
Did some research and found out this issue may probably caused by the version of client_side_validation.
Here by, I provied the version of the gem
formstastic(1.2.4)
client_side_validations(3.1.0)
If you know anything about this, anything, do tell me.
Looks to my eyes like a couple of typos: "Firntastic" and "formstastic". You've probably solved this already, but if not, give those a look.