Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker
George Dean

Beware RubyMine 5!

George Dean
Monday, February 4, 2013

Helps

MySQL lock wait timeout exceeded with timecop and parallel test

(Alexander & Matt)

We want to make sure that our fixtures don’t get out of sync with our test suit. So we wrapped everything into timecop. Now we are getting “Mysql2::Error: Lock wait timeout exceeded” when running “rake parallel:spec”. The offending database call is a “Fixture Delete”.

Interestings

RubyMine 5 scary find & replace

(Will Read)

The latest RubyMine EAP find & replace doesn’t seem to respect exclusions. BE AWARE.

A beta was released over the weekend which may or may not fix it.

Yard

(Matt & Will)

Yard doc is a pretty sweet way to generate some documentation. On our project, we had developed a little system of helper methods for our acceptance test suite (a DSL if you will), and we could not remember the names of everything, so we wanted to organize and expose it. After installing the yard gem (and the redcloth gem), we were able to generate documentation with “yard server –reload”. This runs a web server that we can hit during development that reloads on every request.

http://yardoc.org/

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Glenn Jahnke

Standup 8/11/2011: Whole lotta Rails

Glenn Jahnke
Thursday, August 11, 2011

Ask for Help

“What do you tell Rails the default timezone is if your database has no concept like that?”

The best solution was to convert all rows in your DB to UTC and set Rails to also use UTC. There are MySQL commands to convert whole databases over to UTC, and can be run overnight if necessary.

Interesting Things

There is a new release of Fixture Builder!

  • Supports Rails 2 and 3
  • Supports using existing Rails style fixture files using config.legacy_fixture = Dir[path_to_old_fixtures] in your fixture_builder.rb file
  • Its better tested too!
  • Go grab it at https://github.com/rdy/fixture_builder#readme

Rails 3 Helpers

Rails now includes all helpers across your project in controllers that extends ApplicationController. Apparently there isn’t a setting to override this behavior either, and this is a change from Rails 2 where the scaffold would just include a line at the top of your controller like helpers :all which could easily be deleted.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Installing Rails development stack on OS X Lion

Pivotal Labs
Thursday, August 4, 2011

I recently started working with OS X Lion at home and started researching the best way to get a Ruby on Rails environment up and running quickly.

After a little searching, I found a really well written article by Frederico Araujo over at http://www.frederico-araujo.com/2011/07/30/installing-rails-on-os-x-lion-with-homebrew-rvm-and-mysql/.

Fred’s blog post walks you through step by step getting Homebrew, RVM, Ruby 1.9.2 and MySQL up and running.

It worked perfectly.

Thanks Fred!

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

SF Standup for Monday, 4/25/2011: What gem do you use for file upload?

Pivotal Labs
Tuesday, April 26, 2011

Help

What are projects using for file upload? Paperclip?
Carrierwave?

Most continue to use Paperclip, though a few projects have
successfully used Carrierwave. Carrierwave apparently has better mongo support.

I tried to setup ruby and rails, and installed the latest
mysql gem and I get warning messages about the mysql gem.

Others have experienced this too and offered to help. The main answer
seemed to be “the warnings are lies, it will work.”

Interesting

  • Checkout Pry. It’s an irb replacement that includes tab
    completion and cd and ls for navigating scopes.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Converting Rails application data from MySQL to PostgreSQL

Pivotal Labs
Monday, November 23, 2009

One of our projects had a pending chore in Tracker to move its backend to PostgreSQL from MySQL. This project has about a quarter of a million rows of production data and around a hundred tables in its schema which needed to be exactly migrated into PostgreSQL.

Forklifting the data proved more complicated than expected due to incompatibilities in the two DBMS’ syntax such as in the way string escaping worked, how booleans were represented and a bunch of other small but painful differences. Despite MySQL’s mysqldump utility including a command-line option to write statements in PostgeSQL format, it became clear that it wasn’t going to be simple to create a repeatable procedure to do this work across our environments.

There’s a bunch of information out there about how to approach this problem but none felt right. Most are multi-step manual procedures that require altering a dump file using sed or perl and others require the data to be loaded into an intermediary database and massaged prior to import. After testing some of these approaches, Todd and I decided to timebox ourselves to an hour to test the viability of a Ruby script using the DBI gem to move the data. We came up with:

require 'dbi'
require 'dbd/mysql'
require 'dbd/pg'

begin
  mysql = DBI.connect("DBI:Mysql:source:localhost", "username", "password")
  postgres = DBI.connect("DBI:Pg:destination:localhost", "username", "password")

  mysql.select_all("SHOW TABLES") do |table|
    next if ['schema_migrations', 'sessions'].include?(table.to_s)
    select = mysql.execute("SELECT * FROM #{table}")
    columns = select.column_names.map { |key| ""#{key}"" }.join(', ')
    placeholders = (['?'] * select.column_names.size).join(', ')
    insert = postgres.prepare("INSERT INTO #{table} (#{columns}) VALUES(#{placeholders})")
    select.each { |row| insert.execute(*row) }
    insert.finish
  end
rescue DBI::DatabaseError => e
  puts "Error #{e.err}: #{e.errstr}"
ensure
  mysql.disconnect if mysql
  postgres.disconnect if postgres
end

Our antiquely Perl-like script worked better than we expected — our application started right up with all of its data intact.

Has anybody out there encountered this need before? What kinds of solutions did you come up with?

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Joe Moore

Standup 06/23/2009: Multi-table Inheritance?

Joe Moore
Tuesday, June 23, 2009

Ask for Help

“Has anyone implemented mutli-table (class table) inheritance in Rails, as apposed to single table inheritance (STI)?”

  • There are some plugins that nobody has tried, such as inherits_from
  • What about a view to represent the super set of tables and rows?

“We’re looking for a dead-simple, drop-in JS rating or ‘starting’ plugin.”

Check out the start-rating jQuery plugin. Any other suggestions?

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Standup 11/11/2008: Firefoxen goodness

Pivotal Labs
Thursday, November 13, 2008

Interesting Things

  • In response to our ask for help, Ray Baxter answered us in code with a script called Firefoxen. “It’s a script to automatically configure multiple installations of Firefox so that they open with different profiles.” You can grab Firefoxen on GitHub. Thanks Ray!
  • IE7 sends odd Accept headers (*.* instead of an explicit text/html) which can cause undesired behavior in Rails. Someone suggested manually setting the format in a before_filter:

    params[:format] ||= 'text/html'

    This was discouraged because it can cause problems elsewhere. A better solution was to put the html format at the top of any `respond_to` blocks:

    def show
      respond_to.html # run by default when type cannot be determined
      respond_to.js
    end
    
  • The Ruby MySQL Gem version 2.7 leaks memory for very large queries. The solution is to remove the 2.7 gem and manually install version 2.8 from source. This library is no longer a gem and must be installed from the mysql-ruby-2.8 tarball.

Ask for Help

“As a followup to Firefox SSL certificate problems…”

It turns out that our server running nginx had an old version of OpenSSL installed. Upgrading OpenSSL solved the problem.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Standup 7/24/2008

Pivotal Labs
Thursday, July 24, 2008

Interesting

mysqldump and load

  • There was war story told involving software that’s not generally available. However, one tidbit that may be of general interest is a reminder that you don’t necessarily get a perfect copy of your mysql database when restoring from a dump of that database. Mysqldump by default writes the data of each table preceded by a DROP TABLE IF EXISTS and a CREATE TABLE statement. This covers you in most situations, but misses when new tables have been created since the dump was made — those new tables are not deleted. They may not cause problems, but some systems are sensitive to the existence of those tables, such as rails and the schema_info and schema_migrations tables.

Ask for Help

  • question: Is merb hosting different from rails hosting?
    • answer: no
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Topics

  • agile (778)
  • rails (113)
  • testing (86)
  • ruby (83)
  • ruby on rails (70)
  • jobs (62)
  • javascript (53)
  • techtalk (44)
  • rspec (38)
  • activerecord (29)
  • productivity (29)
  • gogaruco (29)
  • ironblogger (29)
  • git (28)
  • nyc (27)
  • rubymine (25)
  • mobile (21)
  • cucumber (20)
  • bloggerdome (19)
  • process (19)
  • pivotal tracker (19)
  • design (18)
  • jasmine (18)
  • ios (18)
  • webos (17)
  • objective-c (17)
  • android (16)
  • palm (16)
  • "soft" ware (16)
  • fun (15)
  • tracker ecosystem (15)
  • ci (15)
  • cedar (15)
  • rails3 (14)
  • performance (14)
  • gem (13)
  • bdd (13)
  • selenium (12)
  • css (12)
  • goruco (12)
  • bundler (12)
  • tdd (12)
  • meetup (11)
  • railsconf (11)
  • nyc-standup (11)
  • capybara (10)
  • mac (10)
  • mojo (10)
  • chef (10)
  • rubygems (9)
Subscribe to mysql Feed
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >