Tag Archives: rubyonrails

Rails Authentication with Devise and CanCan part 2 – Restful Resources for Administrators

About two months ago I wrote an article on getting started with Devise and CanCan. Since then, I’ve implemented the Devise + CanCan combo on three projects and wrote a couple specs for Ryan Bates to help improve CanCan functionality. This article will focus more on Devise with some CanCan sprinkled in there. [...]
Posted in Software | Also tagged , , , , , , , , | Comments closed

Rails Authentication with Devise and CanCan – Customizing Devise Controllers

I’m tired of spending loads of time creating user authentication systems with permissions or swimming against the current to customize what’s available. There’s great open source stuff out there but until now, I haven’t gotten the full package with really easy customization. The Devise and CanCan combo for user authentication and permissions in Rails is my [...]
Posted in Software | Also tagged , , , , , , | Comments closed

Simple Quarter Select – Rails plugin for Q1,Q2,Q3,Q4 selector

Have you ever wanted a select component for Quaters of the Fiscal Year (Q1,Q2,Q3,Q4)? The Simple Quarter Select Ruby on Rails plugin does it for you. It’s highly configurable and maps to the month of any datetime attribute in your model. Why map the quarter to a datetime attribute? I think the answer is obvious but [...]
Posted in Software | Also tagged , , , | Comments closed

B’more on Rails synopsis – April 2010

B’more on Rails is a community of Baltimore folks who use the Ruby programming language and the Ruby on Rails application framework. Check out our MeetUp page. Below is a brief synopsis from our April 2010 meetup. You can also download the slides here. Bundler is great for gem management. Among other [...]
Posted in Bmore On Rails Review, Software | Also tagged , , , , , , , , , , | Comments closed

Converting Table Data to YAML for Testing in Ruby on Rails

One of my clients has a huge application with no test suite. I am helping the company migrate to Rails 2.3 as well as remove some bottlenecks from their code. I needed to convert around 10 look-up tables to YAML’s so that I could load the data as fixtures and test the application [...]
Posted in Software | Also tagged , , , , , , | Comments closed

Getting jQuery, Rails, and Authenticity Tokens to play nice

For anyone that uses the jQuery AJAX library to send POST requests to their Rails application, you have probably found that the built in Rails CSRF protection does not play nice with your jQuery POST requests. By the way, if you don’t know what CSRF is, check out my Ruby on Rails security presentation. [...]
Posted in Software | Also tagged , , , | Comments closed

Ruby on Rails – Skipping validations based on where object is created

I ran into an issue today where I wanted to skip validations based on where an object was created. To be more specific, I wanted to validate strictly if a “venue” was created through my web interface but I want to skip validations when importing venues. The reasoning is pretty simple, I want [...]
Posted in Software | Also tagged , , , | Comments closed

Back links for your Ruby on Rails application

Here is a nice little helper I wrote to display back links: def back_link link_to "« Go Back", request.env["HTTP_REFERER"].blank? ? "/" : request.env["HTTP_REFERER"] end If you just use the HTTP_REFERER without checking if it’s blank, weird things can happen if someone lands on your page from an email, for example. If you enjoyed this post, make [...]
Posted in Software | Also tagged , | Comments closed

Interning empty string error in Ruby on Rails

I don’t like writing short posts about fixing code errors but I think this one deserves a quick shout out. If you get an error in your Rails application that says “interning empty string”, there could be something wrong with an error message in your validations. For example, I had something like: def geocoding_works_when_geotarget_is_true [...]
Posted in Software | Also tagged , , | Comments closed

Logging your Rails model (the easy way)

In one of my Rails applications, I have some pretty heavy tasks in my models. I decided to log to different files for two of my models so that I can easily make sure these tasks are performed correctly without going through my application log. I also call some of my model methods [...]
Posted in Software | Also tagged , , , | Comments closed