Category Archives: Rails

Partially Solving The Date Validation Deficiency Of Rails 3 And Mongoid 2 Models

A while back, I posted a question on stack overflow on how to properly validate a date input from a text field input, without throwing exceptions when the string provided is not a valid date. ┬áThe core of the problem … Continue reading 

Also posted in Mongoid, Ruby | Leave a comment

Using ActiveSupport::Notifications and ActiveSupport::Concern To Create An Audit Trail

In my previous post, I outlined a scenario that needs to be audited for HIPAA compliance – a patient with a list of medications. Every time a medication is added, updated or deleted, an audit record has to be created … Continue reading 

Also posted in Analysis and Design, Logs, Ruby | 2 Comments

Don’t Do Role-Based Authorization Checks; Do Activity-Based Checks

I’ve built a few dozen security mechanisms in my career. Unfortunately, I kept getting it wrong, hence the need to keep building them. Over the years, though, I learned a number of different ways that a security system can be … Continue reading 

Also posted in .NET, Analysis and Design, AntiPatterns, C#, Model-View-Controller, Ruby, Security | 51 Comments

Embracing Conventions With Namespaced Models And Partials

Six months ago when I started working a contract with Joey Beninghove, I had never done full time rails work. I had played with it a few times and built a few small example apps just to get the hang … Continue reading 

Also posted in AntiPatterns, Model-View-Controller, Philosophy of Software, Principles and Patterns, Ruby | 3 Comments

Keep Your Demo Data Separate From Your Seed Data

File this under the “duh…” category… I don’t know why this wasn’t obvious. Joey and I have been working on our rather large app for a while now, with a bunch of demo accounts and data added with our seed … Continue reading 

Also posted in Data Access, Deployment, Model-View-Controller, Ruby | 1 Comment

Converting A Range And A Value Into A Scaled Value, With A Nice Background Color

I’m working on a web app that receives HL7 formatted medical data through my import utility that I’ve talked about a lot, recently. Once I receive those results, I have to parse them out of the file and then display … Continue reading 

Also posted in Analysis and Design, HAML, Math, Ruby, SASS | Leave a comment

A Better Solution For Partial View Controllers

A few days ago, I wrote about using the Cells gem to create an encapsulated segment of my app, with view and controller, etc. Well, this didn’t work out so well after all. Aside form the initial problem of `content_for` … Continue reading 

Also posted in Model-View-Controller, Quality, Ruby | 1 Comment

Cleaning Up Rails Helper Methods With A Helper Class: Good Idea, Bad Idea, Or ‘Meh’?

I found myself writing a very ugly helper method in my rails ApplicationHelper module: def render_program_dashboard(patient_program) key = patient_program.program.key content_for :css do stylesheet_link_tag “#{key}/patient_program” end dashboard_instance = nil dashboard_class_name = “#{key.to_s.classify}::ProgramDashboard” begin dashboard_class = dashboard_class_name.constantize dashboard_instance = dashboard_class.new(patient_program) rescue Rails.logger.info … Continue reading 

Also posted in Model-View-Controller, Quality, Ruby | 2 Comments

Cells: Partial Controllers And Views For Rails 3

I’ve got a sort-of meta-application that I’m building in Rails 3 for a client. The core of the application is a framework on which we build various “Programs” that a patient can participate in. On the Patient Profile screen, a … Continue reading 

Also posted in Model-View-Controller, Quality, Ruby | 5 Comments

Solving Some SSH Issues For Deploying Rails Apps

So you think “The Rails Life” is all unicorns, rainbows and glitter? Yeah. Guess again. Right now it feels more like a glitter cannon shredding a unicorn into a rainbow colored bloody pulp… Joey and I are deploying our rails … Continue reading 

Also posted in Command Line, Deployment, Git, Linux, OSX, Rake, Ruby, Vlad | 3 Comments