Browsing all articles in Programming

Overriding Rails’ automatic timestamps: updated_at & created_at

Posted Posted by Wes in Ruby on Rails     Comments No comments
Jul
5

When converting something in a project, I found that I needed to updated a field for every record in a Request table. No problem, except this client grabs a SQL dump and run reports on it. So, Rails’ automatic timestamping of the updated_at field made all of the Requests look like they’d just been updated. Which they had, but not by users.

So, this rake task will reset all of them, presuming you have something to set them to. In my case, I found the latest comment date and used that, but you could figure it out some other way.

git: pull is not possible because you have unmerged files.

Posted Posted by Wes in Version Control     Comments No comments
Jul
1

I saw this error message the other day and I had no clue what it meant. I’d never seen that error before!

For reference, I was trying to pull from a remote branch and got the error message:

Pull is not possible because you have unmerged files.

A google search revealed this commit (d38a30df7dd54c5c6883) to the git source on January 12, 2010.

The error messages have been updated to be much clearer. Before, you’d get “needs merge” or “error building trees” errors, which didn’t really mean much.

In this case, I was pulling in many commits and had a conflict partway through. I just needed to resolve the files, add/delete them, commit the result and then continue with the pull.

Jammit Warning: Asset compression disabled — Java unavailable (Mac/Apple)

Posted Posted by Wes in Programming, Ruby on Rails     Comments No comments
May
10

I set up Jammit locally on my Mac running Leopard and was receiving this error:

Jammit Warning: Asset compression disabled -- Java unavailable

I checked out Java:

> java -version
java version "1.5.0_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03-333-9M3125)
Java HotSpot(TM) Client VM (build 1.5.0_22-147, mixed mode, sharing)

Odd.  Poking into the jammit source, I saw that java 1.4 is required to use the YUI javascript compressor, but I had selected the google closure compiler which requires java 1.6, hence the [unclear] error message.

On Leopard, if you’ve run all your System Updates, you probably have java 1.6, but you have to select it as the default:  Applications > Utilities > Java Preferences > drag new version to top

Kansas City Ruby Users: Luke Pillow on Jeweler

Posted Posted by Wes in Kansas City Ruby User Group, Ruby, Ruby on Rails, Videos     Comments No comments
Mar
13

Luke Pillow present to the Kansas City Ruby Users Group on Jeweler and Gemcutter rubygems.org.

Also, Luke is helping to organize the Ruby Midwest conference, so you should check that out.

Kansas City Ruby Users Group | March 2010 | Luke Pillow | Jeweler for Rubygems | kcrug.org from Wes Garrison on Vimeo.

Kansas City Ruby Users: Ryan Smith on Heroku

Posted Posted by Wes in Kansas City Ruby User Group, Ruby, Ruby on Rails, Videos     Comments 2 comments
Mar
12

Ryan Smith presents to the Kansas City Ruby Users Group on Heroku: why it’s wonderful for deploying Ruby on Rails applications, how to set up a new application and deploy it to Heroku in minutes, and how to use Heroku add-ons to support search.

Kansas City Ruby Users Group | March 2010 | Ryan Smith | Heroku | kcrug.org from Wes Garrison on Vimeo.

“warning: updating the current branch” when pushing to a git repository

Posted Posted by Wes in Version Control     Comments 1 comment
Mar
8

I pushed some changes after updating git on my server to git 1.6+ and now I get this:

$ git push origin master
...
warning: updating the current branch
warning: Updating the currently checked out branch may cause confusion,
warning: as the index and work tree do not reflect changes that are in HEAD.
warning: As a result, you may see the changes you just pushed into it
warning: reverted when you run 'git diff' over there, and you may want
warning: to run 'git reset --hard' before starting to work to recover.
warning:
warning: You can set 'receive.denyCurrentBranch' configuration variable to
warning: 'refuse' in the remote repository to forbid pushing into its
warning: current branch.
warning: To allow pushing into the current branch, you can set it to 'ignore';
warning: but this is not recommended unless you arranged to update its work
warning: tree to match what you pushed in some other way.
warning:
warning: To squelch this message, you can set it to 'warn'.
warning:
warning: Note that the default will change in a future version of git
warning: to refuse updating the current branch unless you have the
warning: configuration variable set to either 'ignore' or 'warn'.

Woah! After some research, this is because I didn’t set up my remote folder as “bare”. A non-bare repository has a working copy attached to it, and this warning is telling you that said working copy exists and is currently checked out to the branch you’re trying to push to.

This is bad, because if you were pushing to a co-worker’s machine, then when they go to commit or run a diff, things will go awry. In this case, I just didn’t set up the repository correctly (it was the first one I’d done!) so I wasn’t in danger of losing anything.

The fix is to use --bare:
git init --bare or git clone --bare

Installing sqlite headers on ubuntu (sqlite3.h not found)

Posted Posted by Wes in Ruby, Ruby on Rails     Comments No comments
Mar
5

I was setting up Integrity for the first time and ran into this on my server when bundling gems:

~$ bundle install
...
Installing do_sqlite3 (0.10.0) from rubygems repository at
  http://gemcutter.org/ with native extensions
  /usr/local/lib/site_ruby/1.8/rubygems/installer.rb:482:in
  `build_extensions':
ERROR: Failed to build gem native extension.
  (Gem::Installer::ExtensionBuildError)

/usr/bin/ruby1.8 extconf.rb
checking for sqlite3.h... no
*** extconf.rb failed ***
...

The key is the line: checking for sqlite3.h... no
The do_sqlite3 gem gets compiled natively, but the development headers weren’t installed on the system and so the compilation won’t work.

Install them:

~$ sudo apt-get install sqlite3
~$ sudo apt-get install libsqlite3-dev

Then, re-bundle:

~$ bundle install

Kansas City Ruby User Group: Kyle J Ginavan on Progressive Enhancement

Posted Posted by Wes in Kansas City Ruby User Group, Ruby, Ruby on Rails, Videos     Comments No comments
Feb
12

Presentation: Kyle Ginivan on Progressive Enhancement

Progressive enhancement is a strategy for web design that emphasizes accessibility, semantic markup, and external stylesheet and scripting technologies. Progressive enhancement uses web technologies in a layered fashion that allows everyone to access the basic content and functionality of a web page, using any browser or Internet connection, while also providing those with better bandwidth or more advanced browser software an enhanced version of the page.
read more

Capistrano deploy error "fatal: unable to create '.git/index.lock': File exists"

Posted Posted by Wes in Ruby on Rails, Version Control     Comments No comments
Oct
21

This isn’t specific to capistrano, necessarily, but I ran into it deploying.

fatal: unable to create '.git/index.lock': File exists
read more

blog Categories

about databasically

We live and work in Kansas City, USA.

We're passionate about helping small businesses succeed and want to help you use technology to get more done.

From server, desktop, network management to programming custom web applications in Ruby on Rails, we're here to lend a hand.

Contact us if you have any questions!