Rails 3.0 Offline Application – Lessons Learned

Posted on May 3, 2012 in Blog

We recently deployed an offline enabled page in an existing Rails 3.0 application.  We started understanding how to implement offline functionality be watching the railscast on offline apps part 1.  In this blog post we’d like to share what we had to learn beyond what Ryan Bates outlined in that screencast, especially when it came […]

Rails custom validations: Get field values before type casting

Posted on Apr 25, 2012 in Blog

I ran into a problem with form validation in one of our applications a few days ago.  Basically we have a form that allows a user to pick a question, and depending on the type of question picked it expects a specific type of answer from the user. Initially this form was coded to accept […]

RSpec Integration Tests with Capybara and JavaScript

Posted on Feb 9, 2012 in Blog

Make sure you do this in your spec_helper.rb: RSpec.configure do |config| config.use_transactional_fixtures = false end Or it will seem like the data your fixtures or factories are creating is not available.  For example, I was creating a user and then attempting to login as that user, yet I could not because the new user was […]

Rails conditional validations dependent on parent model

Posted on Dec 20, 2011 in Blog

I have a report model that has_may observations. has_many :observations I have a conditional validation in observations that depends on an attribute of report. When I wrote this code: validates_presence_of :type_of_monitoring, :if => Proc.new { |observation| observation.report.report_type.eql? “SM” }, :message => “is required” I got the following error: NoMethodError (undefined method `report_type’ for nil:NilClass): When […]

TypeError: can’t define singleton method “encode_with” for BigDecimal

Posted on Jul 23, 2011 in Blog

Today I refreshed my development machine.  When I got my Rails 3.0.7 application up and running my tests were not passing due to the following error: TypeError: can’t define singleton method “encode_with” for BigDecimal This was being triggered by a to_yaml call on the BigDecimal. I upgraded my Rails app from 3.0.7 to 3.0.9 and it […]

RefineryCMS – implementing the portfolio

Posted on Apr 7, 2011 in Blog

If you want to show a gallery or listing of your portfolio items then make sure you go to the settings page and set Settings – Portfolio Has No Index – false Also, to make sure that your portfolio uses the portfolio pages instead of your default page.  Go to the advanced settings for your portfolio […]