Read the latest web development and design tips at Fred Wu's new blog! :-)
Poke me on GitHub

Posts Tagged ‘Rails’

Rails, jQuery, Dating, etc

Here’s a few things you might be interested in from the past few weeks. :-)

[Rails] Inherited Resources Views Now Supports Rails 2.x

I have just pushed a commit that added Rails 2.x compatibility to Inherited Resources Views. Please give it a spin! :-)

Reinvigorate – Realtime Website Traffic Analysis

It isn’t the first time realtime website traffic analysis has been introduced. Reinvigorate is one of the services that provides realtime traffic tracking and analysis.

Poke me on Github! :D

I have just added a Github ribbon to my blog (look at the top left corner!). Please feel free to poke me! :D

[Rails] Releasing Inherited Resources Views – DRY Your View Files

Using Inherited Resources is an excellent way to reduce the amount of repetition in your controllers. But what about views? A lot of times resources share the same views, so why not DRY ‘em up using Inherited Resources Views!

[jQuery] Releasing Inline Confirmation, Confirm Actions Done Right

In a web app, it is very common to have actions that destroy (delete/remove) data. These actions, if you don’t already know, should always map to POST methods. On top of that, because these actions are destructive, the UI should always ask the user for confirmation…

I’m Now a Ruby on Rails Contributor

I am extremely happy that my patch was accepted, so I am now one of the 1600 odd people who have contributed to the Rails project! :D

[PHP] Releasing KThrottler, A Kohana Module for Throttling Actions

Similarly to Action Throttler for Rails, KThrottler is an easy to use Kohana module to quickly throttle application actions based on configurable duration and limit.

#whatdatingislike What Dating Is Like

Dating girls is like calling a callback function without knowing the accepted arguments. Random exceptions would throw right in your face.

Dating girls is like running prerelease ruby gems. Things might not be compatible, there might be memory leaks and other weirdnesses…

[Rails] Introducing Datamappify – ActiveRecord Without DB Migrations

ActiveRecord is without doubt the de facto ORM library for Rails and many Ruby web frameworks. Many developers however, do not like database migrations and prefer to use DSL for data mapping. Datamappify is created with the sole purpose of getting rid of the DB migration headaches…

Related posts

What You Might Have Missed, Again :-)

Here are some of the posts you might be interested in from my Tumblr blog.

[jQuery] Endless Scroll Updated, Now Works with Any DOM Elements

jQuery Endless Scroll has now been updated to work with any DOM elements, not just $(document) …

[Rails] Releasing Action Throttler, A Rails Plugin for Throttling Actions

Sometimes we would want to throttle certain application actions. For instance, a user should only be allowed to send x amount of emails to other members of the site in order to reduce the spam risk …

A Whole World of Difference: Phusion Passenger Apache to Nginx, Ruby Enterprise Edition 1.8.6 to 1.8.7

Yesterday we have launched the new design of Creattica. It runs well during the testing and staging phase, unfortunately the server quickly became overloaded and unresponsive after the relaunch was made public …

[Rails] Use App_Config For Your Application Specific Configuration

A simple Google search will reveal that there are a number of different App_Config plugins for Rails. After comparing them side by side, I have decided to use the one by Christopher J. Bottaro …

[Rails Tip] Model Attributes Not Updating? `reset_column_information` To the Rescue!

So you were wondering why some of your model attributes weren’t updating properly? Well, it is perhaps because the db schema has changed but the changed schema has not been passed onto ActiveRecord, as is often the case in DB migration …

[jQuery Tip] Traverse/Parse HTML String

When you are getting an HTML string from an external source (e.g. from an AJAX get result) and you want to rip out a certain part of the HTML source, you need to make sure that the ‘certain part’ is not at the top level of the HTML source …

[Rails Tip] DataMapper M:M Association Bug and Workaround

It was confirmed that DataMapper is incorrectly setting table names in SQL JOINs …

[Rails Tip] DataMapper Timestamps Bug and Workaround

It has been confirmed by DataMapper’s core developer Martin Gamsjaeger (snusnu) that it is a bug …

[Rails Tip] Run Specs Faster!

If you are using rake spec to run the specs. Try using spec spec instead! It avoids doing some preliminary tasks and therefore is quicker to execute …

[Rails] Run Queued Tasks Using ‘delayed_job’, Now With Intervals!

If you don’t already know, ‘delayed_job’ is a database based asynchronously priority queue system extracted from Shopify …

Related posts

What You Might Have Missed

Below is a list of the posts that might interest you:

[Rails Tip] Making i18n Forms, the Easy Way

Web applications normally have many forms. Building forms is always a mind-boggling task because it involves repetition and chaos. A shortcut is to use …

Advanced Search Query on GitHub

Did you know, you can perform advanced search queries on GitHub? For example …

[Rails] Use HAML templates with Devise

If you are a Rails developers, chances are you have heard of, or are using either Devise or HAML in your projects. And if you’re like me who uses both, then surely you’d wish these two worked together …

Use the ‘textmate’ Command to Quickly Install Bundle Files

Initially developed by Yehuda Katz, the Textmate gem is an extremely handy tool for installing and managing your Textmate bundle files. The tool works very well, for the most part…

Related posts

Using Ruby MySQL Gem with MAMP 1.8.x on Snow Leopard

Being primarily a PHP developer, I always use an AMP package no matter what development platform I am on. So when it comes to developing Ruby/Rails applications on the same platform, I’d like to use what is already available.

Mike Boone has posted a very useful tutorial on how to get MySQL gem and MAMP 1.7.2 up and running. So, to recap and make the tutorial compatible with Snow Leopard and MAMP 1.8.x, here is what you need to do:

  1. Download the latest MAMP dmg file.
  2. Download the 1.8.2 (or whichever the latest one you could find) components file from this page.
  3. Unzip, mount the dmg, then copy the MySQL source file (mysql-5.1.37.tar.gz) to somewhere on your hard drive.
  4. Untar the MySQL source file, and `cd` to the source file directory.
  5. Compile the library:


    $ ./configure --with-unix-socket-path=/Applications/MAMP/tmp/mysql/mysql.sock --without-server --prefix=/Applications/MAMP/Library

    $ make -j2

  6. Copy the compiled libraries into MAMP:

    $ cp libmysql/.libs/*.dylib /Applications/MAMP/Library/lib/mysql

  7. Copy the MYSQL headers into MAMP:


    $ mkdir /Applications/MAMP/Library/include

    $ cp -R include /Applications/MAMP/Library/include/mysql

  8. Install the Ruby MySQL Gem, on Snow Leopard:


    $ sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config

    On Leopard:


    $ sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config

Enjoy!

EDIT @ 2009-11-23: If you’re still experiencing problems (perhaps with RVM), try adding “/Applications/MAMP/Library/bin/” to your $PATH in “~/.bash_profile”.

Related posts

Comparison: Ruby vs PHP, the Pros

Just to be clear, this is NOT a fanboyism post nor do I encourage the debate between which language is superior. My personal belief is to use the appropriate tool for appropriate projects.

PHP Pros

  • Widely available libraries (including PEAR and PECL)
  • An absolutely outstanding online manual
  • Relatively easy to learn (can hack together some code without deep understanding of the language)
  • Widely used (easy to find clients, etc)
  • Most if not all control panels have PHP integration
  • Development packages (XAMPP, WAMP, MAMP, LAMP, etc)
  • C style syntax (easier transition for people with C/C++/Java background)
  • Powerful array feature (Ruby’s equivalent to PHP’s associative array is Hash, which is not interchangeable with array)
  • PhpDoc is better than RDoc (this might be because I am too used to PhpDoc)

Ruby Pros

  • Fully object oriented
  • Rake (Ruby’s Make)
  • RubyGem (Ruby’s apt/yum)
  • Code blocks
  • ‘Ghost’ classes
  • Modules (aka namespace/package, PHP 5.3 will have namespace too, but with much uglier syntax)
  • lambda functions (PHP 5.3 will have this too, but not as powerful)
  • Children-aware parent classes (‘inherited’ hook)
  • Multi-inheritance through Mixins (PHP is single-inheritance)
  • Ruby 1.9 is unicode friendly (PHP 6 will be)
  • For what I do, Ruby on Rails > all PHP frameworks combined
  • Regular Expression built into the language core

I am pretty sure there’s heaps of pros for both PHP and Ruby missing from the list, but at least it gives you a rough idea on what to look for if you are not very familiar with them.

Please share your experience with us too (and I will update this post accordingly). :)

Related posts

Ruby on Rails, Passenger (ModRails) vs CodeIgniter and Kohana

Disclaimer: This is a very simple, ‘Hello World’ benchmark which has no impact to any real world applications. A more thorough benchmark test (by building two real world applications) is planned. :)

Disclaimer 2:I apologise for posting such a useless benchmark (I certainly didn’t expect it to hit the DZone front page), but I think most of you missed the point. I merely posted this as a result of surprise (to me anyway). At a later stage I will conduct a much more meaningful comparison between some of the frameworks. Until then, please ignore this post. :)

Last few days I have been playing with Ruby and Rails, again.

Today, when someone was asking on a forum about the efficiency of web frameworks, I thought I’d give the few frameworks I work with some more benchmark testing.

So I went ahead and benchmarked CodeIgniter, Kohana and Rails, using a simple ‘Hello World!’ page. Now before I post any benchmark results, you should know that I have previously done a benchmark test on CodeIgniter, Kohana and CakePHP. CodeIgniter and Kohana shared similar results.

(more…)

Related posts