ruby

RubyMotion – PullToRefresh

To add Sam Vermette’s SVPullToRefresh to your RubyMotion project: Add the SVPullToRefresh pod Add the Quartz Framework # RakefileMotion::Project::App.setup do |app| # … app.frameworks += [‘QuartzCore’] app.pods do pod ‘SVPullToRefresh’ # … endend # Then in your controller def viewDidLoad # …. tableView.addPullToRefreshWithActionHandler Proc.new { loadMagicalData(tableView) # do some other magic # then don’t forget to: tableView.pullToRefreshView.stopAnimating }# …

Using NUI with RubyMotion

NUI is an open-source library that allows you to style your iOS applications using CSS-like files and syntax. In my opinion, NUI carries few benefits over its commercial, KickStart backed, competitor Pixate. First; NUI allows you to style your application on the fly while it’s running in the simulator. And Second; NUI styled-elements are not masked/wrapped in their special...

Consultancy Masterclass

Last weekend, I sat through the two-day Consultancy Masterlcass by Brennan Dunn & Obie Fernandez. Both Brennan and Obie have extensive experience building their own successful consultancy firms. The class was insightful and full of those ‘from the trenches’ experiences. What was of significant value is the knowledge transparently shared by students and alumni. All of whom are of...

Rails and inner query choices

Consider that we have two models; Well and SurveryPoints . A Well represent an oil/gas/water well, each with multiple SurveyPoints. A SurveyPoint represent the well’s coordinate at a certain depth. class Well < ActiveRecord::Base has_many :survey_pointsendclass SurveyPoint < ActiveRecord::Base belongs_to :wellend Say, we’d like to implement a filtration mechanism that allows us to query the wells – and for...

JRuby – can’t convert Hash into String

I’ve recently upgraded a JRuby/Rails application from JRuby 1.6.3 (1.8 compatibility mode) to 1.6.8 (1.9 mode). Everything was working out fine except for actions relying on internal CSV library (FasterCSV in 1.8 mode). The error “ was thrown as CSV tries to generate the csv string. This had the hallmarks that the application was still under the 1.8 mode...

newrelic – undefined method `-’ for nil:NilClass

Using JRuby with trinidad (developer mode) – I was intermittently getting this error. Apparently thrown as estimated_time for the transaction was returning nil. I was also having all sorts of other issues (undefined method `metric_name’ for nil:NilClass) with all newrelics action summaries. To resolve (following suggestions on the trinidad google group): {% highlight ruby %} config/initializers/newrelic.rb if defined?(JRUBY_VERSION) &&...

JRuby/Rails Streaming in development environment (and beyond)

Rails streaming is a great feature that allows you to optimize on server resources when dealing with large generated content. However – it might be a bit tricky to validate and test in local development. First off – a local server that supports streaming is required. The only one I could find was trinidad which is moving to the...

JRuby and Polyglot

JRuby 1.5.6 (I know. Old) Rails 3.0.1 Polyglot 0.3.3 UPDATE: see easier fix below Getting the following error when bundling: {% highlight ruby %} Java::JavaLang::ArrayIndexOutOfBoundsException: An error occured while installing polyglot (0.3.3), and Bundler cannot continue. Make sure that gem install polyglot -v ‘0.3.3’ succeeds before bundling. {% endhighlight %} JRuby YAML parser is erring with this version of...

Rails, nested attributes and before_save callbacks

I had a Project model with a many ProjectWell (as in oil) association. Taking advantage of the accepts_nested_attributes, I was able to persist both Project and ProjectWell attributes through a single web form. {% highlight ruby %} class Project < ActiveRecord::Base has_many :project_wells accepts_nested_attributes_for :project_wells end class ProjectWell < ActiveRecord::Base belongs_to :project end {% endhighlight %} Now, the ProjectWell...