Error Logging in Rails - ruby-on-rails

My team has recently switched to rails, and we're yet to implement an error logging solution for our project.
I'd like something like Elmah - http://code.google.com/p/elmah/ - where the errors and details are logged and easily accessible.
Are there any suggestions?
Thanks!

I use and like Hoptoad (disclaimer: I'm not affiliated with them in any way). Another popular service in the Rails world for doing the same thing is Exceptional.

I did a quick search for a gem on Rails log analyzing and came across this awesome looking project called request-log-analyzer lead by wvanbergen. You can find the project on github: http://github.com/wvanbergen/request-log-analyzer.
Also, take a look at some sample output: http://wiki.github.com/wvanbergen/request-log-analyzer/sample-output
This would be a very simple and effective way of tracking request-related errors, obviously.
For non-request-related errors that you'd like to log, I'd recommend just using the built-in Logger and seeing if either 1) request-log-analyzer can interface with a non-request log file or if 2) you can play with the request-log-analyzer to also parse and display your own error log file in a similar fashion.

Related

Setting up ruby on rails gem ga_events

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.

Visual Log Viewer for Ruby On Rails 4.2

I have worked previously on Laravel 4 and there is an awesome log viewer tool for it laravel log viewer view demo
I'm looking something very similar for Ruby on rails 4.2, if you guys know any good visual logging GEM for Rails 4.2 please let me know..
From code I need to log at different log levels, and this tool should visually organize my logs, thanks..
This should get you started https://github.com/shadabahmed/logstasher
As it says
This gem is heavily inspired from lograge, but it's focused on one
thing and one thing only. That's making your logs awesome like this
More here http://www.shadabahmed.com/blog/2013/04/30/logstasher-for-awesome-rails-logging/
Another simpler gem is https://github.com/dieb/browserlog - it just shows your default rails logs, in the browser, with syntax highlighting.
Also see:
https://github.com/discourse/logster
We use it in production across thousands of Discourse instances.

How do I debug errors with ActiveAdmin with Ruby on Rails?

There is a rails application that uses bunch of gems one of which is ActiveAdmin.
Dashboard works OK, but other custom tabs gets a 500 response.
How do I enabled debugging/logging inside ActiveAdmin gem to get to the bottom of this problem?
Corresponding generic question is this: what are the ways to enable debugging on rails apps with multiple gem dependencies?
1) Check your development.log file after hitting the custom tab page and see where the error was. The log should give you a stack trace or at least tell you the last controller that was hit. You can use this information to work backwards and find out where you code is breaking.
2) Once you have found the broken spot in the code you can use raise or pry debugger to inspect variables/methods to help you debug.
This turned out to be a version mismatch between the mongoid interface and the active admin interface.Thanks for all the help.

Well built rails code for download

I want to get into rails by examining well built code
where can i find typical open source rails project that i can download
and learn from ?
i'm interested in facebook connect integration (facebooker), tag clouds, searching in
my website
I'm not looking not tutorials or screen casts
Thanks!
This question gives a good list
a list of projects with good test-suites
a list of open source rails apps to learn from
Have a browse of ruby tool box and download some open source. For example there's refinery and zena, two content management systems and Rboard, a forum. Depends what you want really but there's plenty out there. Ruby toolbox entries are ordered by github watchers and forks to give you an idea of their popularity.
I really like looking at the commits in teambox.
I find it a bit more complicated. But there's also spree.
There's also devise which is really interesting to look at too.
Finally, I'd recommend you to follow the rails commits (it's the only commits feed I have in my Google Reader).
Gady, this is an extremely rich topic you're asking about and resources are all over the internet. Try starting at http://rubyonrails.org/.
You should be able to find tens of questions just like yours (asked and answered) by searching SO at the top bar.
For Rails, part of it is the building process, so one feasible approach is to read a tutorial like http://railstutorial.org/book
then when in Chapter 2, you will use Scaffold, and at that time, you will have some basic code to look into how a basic Rails app is.
I also suggest you use source control like Git, Mercurial, or SVN to commit different phases of the project, from creating the rails project and then after each step, so you can diff what the changes are during each step.
If you already have Ruby 1.9.2, Rails 3.0.1, and sqlite3, then you can
rails new myproj
cd myproj
rails generate scaffold foo name:string salary:integer gpa:float note:text
rake db:migrate
rails server
and now you can use http://localhost:3000/foos to create, display, update, delete the foo records, and have quite a bit of source code to look at. Most of the customizable code is in app, with css and javascript in the public folder.
Ryan Bates has an excellent series of videos.
http://railscasts.com/
An extremely valuable resource.
Radiant is a CMS that you can download for free and see how it works. It is a great piece of code to look at and see how it works.
I guess that most open source Rails projects are shared on Github, so it may be interesting to browse its Ruby section and look for most watched or most forked projects:
http://github.com/languages/Ruby
Steady stream of new interesting projects to take a look at :)
And don't forget the official:
guides.rubyonrails.org
well there is one "bigger" project on github, waiting for downloading and contribution...
but it's a little controversial because of the security issued they have (had?)
It's still worth a look:
http://github.com/diaspora/diaspora

Creating a basic facebook application with Rails

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.

Resources