WebAppers

June 26th, 2007

WebAppers – Only the Best and Free Resources for Web Application Developers

Where has this been all my life?


has_one :through

June 20th, 2007

Via: http://idm.s9.xrea.com/ratio/2006/08/04/000496.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class ActiveRecord::Associations::HasOneThroughAssociation < ActiveRecord::Associations::HasOneAssociation
  private
    def construct_sql
      @finder_sql = "#{@reflection.through_reflection.table_name}.#{@reflection.through_reflection.primary_key_name} = #{@owner.quoted_id}"
      @finder_sql << " AND (#{conditions})" if conditions
    end

    def find_target
      @reflection.klass.find(:first,
        :select => @reflection.options[:select] || "#{@reflection.table_name}.*",
        :conditions => @finder_sql,
        :order => @reflection.options[:order],
        :include => @reflection.options[:include],
        :joins => "LEFT OUTER JOIN #{@reflection.through_reflection.table_name} " +
                  " ON #{@reflection.through_reflection.table_name}.#{@reflection.source_reflection.primary_key_name} " +
                "    = #{@reflection.table_name}.#{@reflection.klass.primary_key}"
      )
    end
end

module ActiveRecord::Associations::ClassMethods
  def has_one_with_through(association_id, options = {})
    if options[:through]
      reflection = create_has_one_through_reflection(association_id, options)
      association_accessor_methods(reflection, ActiveRecord::Associations::HasOneThroughAssociation)
    else
      has_one_without_through(association_id, options)
    end
  end

  alias_method :has_one_without_through, :has_one
  alias_method :has_one, :has_one_with_through

  private
    def create_has_one_through_reflection(association_id, options)
      options.assert_valid_keys(
        :class_name, :foreign_key, :remote, :conditions, :order, :include, :dependent, :counter_cache, :extend, :as, :through
      )
      create_reflection(:has_one, association_id, options, self)
    end
end

CSSEdit with Rails

June 19th, 2007

I love CSSEdit. It has to be one of the prettiest OS X programs out there, and it makes editing CSS a breeze.

The one thing that has annoyed me though has been using the override feature when developing with Rails. Rails likes to append an asset id on every CSS, JavaScript, and image file that it serves. If I have screen.css, Rails would embed it like screen.css?123456789. So every time I would reload the page in CSSEdit, the style sheet override would be broken, because the asset id would be different.

There is a fast and wonderfully simple solution. Just add this line in config/environments/development.rb:


ENV["RAILS_ASSET_ID"] = ""

Voila! No more asset id in development mode. No more broken overrides.

Credit: MacRabbit Blog


Safari on Windows. Safari on Mac. Safari on iPhone.

This is potentially one of the most important developments since the invention of the web browser itself. Apple apparently intends to beat Microsoft at its own game, dominating the web browser market. And glory be – will not we web developers be happy to someday see the demise (unlikely as it may seem) of the inferior Internet Explorer? Or, as seems more likely, the steady increase in the overall quality and capability of the Web as a platform.

But that is only part of the picture. The new ubiquitous Safari gives Apple (and us) a platform through to deliver media and applications to every computer user, regardless of platform, location, or operating system preference.

Today’s announcement that the iPhone will support third-party software through Safari means that the average web developer like you and I will be able to develop rich applications for the iPhone with a minimal learning curve. It also means that existing applications like BaseCamp, Backpack, and our own CrossConnector may be easily ported to a native iPhone application.

With high-bandwidth Internet almost universal, a common platform on every conceivable Internet device, and a framework that lets you churn out new applications in no time, imagine the applications you could develop.


WWDC

June 11th, 2007

Ooooo this is so exciting. Today kicks off Apple’s WWDC (WorldWide Developer’s Conference) 2007. If you’re like me you’re hunched over your feedreader waiting for the keynote at 10:00am PDT. (Not really, I’m actually getting work done.)

Yes, I am an Apple fanboy. Normally companies treat me, a customer, as an antagonist. Apple is one of the few companies I work with that makes me feel really, really happy on a regular basis. Plus they have really cool products. Ok, let’s have that iPhone.

WWDC live coverage from MacRumorsLive

News