Important detail for Rails apps at a sub-uri

When using passenger with an app deployed to a sub-uri most details of app paths are handled automatically. However, when deploying an app the precompiled assets using helpers such as asset_path will get the wrong path because it doesn’t know about the sub-uri. The solution is to set Rails.application.config.action_controller.relative_url_root in an initializer or environment to …

Continue reading ‘Important detail for Rails apps at a sub-uri’ »

Ruby best practices: count, length, size

When to use which: Hash size and length both call RHASH_SIZE which is O(1) count is enumerable.count which is O(n) – use only with block best practice: length without block, count with block Array size is an alias for length length calls RARRAY_LEN which is O(1) count is O(n) – use only with block best practice: length …

Continue reading ‘Ruby best practices: count, length, size’ »

Performance problems with FreeTDS

So FreeTDS is the glue between a linux systems and SQL Server, among other things. For my purposes I’m mainly using it to run Rails with a SQL Server backend. My understanding is that the alternatives to FreeTDS are Microsoft’s SQL Server ODBC Driver 1.0 for Linux or, if using JRuby, Microsoft’s JDBC Driver for SQL Server. But why …

Continue reading ‘Performance problems with FreeTDS’ »

Rails Database Config Parameters for PG Gem

I’ve noted how difficult it is to get a complete list of parameters that can be used in the Rails’ config.database.yml file. I understand this is because there are different parameters for the different library layers. Still, I would like a more complete list somewhere, especially given that the parameter names can be confusingly similar …

Continue reading ‘Rails Database Config Parameters for PG Gem’ »

Integrating R and Ruby

I did my time with rsruby, rinruby and Rserve-Ruby-client. In retrospect I should have trusted the Rserve-Ruby-client readme which details the problems with rsruby and rinruby. rsruby – dealbreaker is that this is not stable, there are a few other downsides including complex data conversions and compilation issues but enough said. rinruby – slow, but more importantly fails …

Continue reading ‘Integrating R and Ruby’ »

Fixing “uninitialized constant” errors in rake tasks when using Rails threadsafe! mode

I ran into this problem where I was getting “uninitialized constant” errors when running rake tasks. These are tasks which had been working and I verified that the proper paths were set (eager_load_paths). When searching I saw information about config.threadsafe! being a problem so I disabled it and the problems vanished. However, I wanted to …

Continue reading ‘Fixing “uninitialized constant” errors in rake tasks when using Rails threadsafe! mode’ »

gems for validating email and urls in rails

Validating URL Addresses http_url_validation_improved (1.3.1) – uses Addressable::URI.parse, can check url connectivity url_validation (1.0.0) – uses Addressable::URI.parse, can check url connectivity url_validator (0.1.0) – uses Addressable::URI.parse validate_url (0.2.0) – simple, Rails 3 only, uses URI.parse validates_url_format_of (0.3.0) – Rails 2 and 3, uses regexp Obviously people’s needs will differ but I think validate_url suites my …

Continue reading ‘gems for validating email and urls in rails’ »

Researching Redis on Rails

I’ve been researching how good a fit Redis might be for a project or 2.  One project needs a memory based key-value store generally without persistence, which would seem to suggest memcached.  However, there may be times where persistence across reboots may be desirable and Redis’ atomic operations and data types may also be useful.  …

Continue reading ‘Researching Redis on Rails’ »

how to disable Rack::Cache in Rails 3.1

Couldn’t find this anywhere but what I found worked was to put this in config/application.rb: require ‘rack/cache’ config.middleware.delete Rack::Cache This did fix the issue that sent me to this, as many people are likely to run into. The issue was that since Rack::Cache uses the default Rails FileStore that lots and lots of small files …

Continue reading ‘how to disable Rack::Cache in Rails 3.1’ »

Fixing netbeans in ubuntu

Netbeans has some issues in Ubuntu 10.10 and 11.04.  One of the most serious is that javascript syntax highlighting does not work.  Another is that Rails 3 applications do not run or debug correctly.  I found the solution to be going to “Tools – Plugins -Settings” and enabling the “Netbeans” update center.  Then by going …

Continue reading ‘Fixing netbeans in ubuntu’ »