Tips 'n Tricks

Details for iPhone web app development (UPDATED)


Some details have been made available by The University of Washington on how to develop web applications for iPhone - lots of basics in there, like keeping a good separation of HTML and CSS, but also some specifics on e.g. the screen width, some limitations in place, etc. Mandatory reading for anyone doing iPhone apps.

UPDATE: Apparently someone didn't like the info being posted publically, so someone posted a copy of the iPhone details elsewhere.

button_to HTML options not completely intuitive


While working on a site in Rails tonight I was adding a button_to that I wanted a JS confirmation requester. Well, based on my albeit beginner knowledge of Rails I thought the following would work:
:empty, :confirm => "Really empty your cart?" %>
As it turned out this wouldn't work, it kept adding "?confirm=Really empty your cart?" to the URL instead of doing a popup. A bit of fiddling later I realized that to work correctly the additional arguments to button_to need to be arrays, e.g.:
:empty}, {:confirm => "Really empty your cart?"} %>

Nested controllers with Goldberg (UPDATE: fixed in v0.2.1)


The Rails plugin Goldberg is really quite good for kick-starting a site with its permissions system and basic CMS. There is one small bug in it though, it doesn't like adding nested controllers in the admin console. There is, however, a simple work-around: simply go to e.g.:

That will load up the New Controller page which lets you type in a controller name and set the default permissions for it, so all you have to do is type in the name of your new controller, e.g. admin/news, and it'll work just fine from there!

UPDATE: FYI this has been fixed in the latest v0.2.1.

Variables in ColdFusion Components (CFCs)


A couple of tips for anyone working with ColdFusion Components, aka CFCs:

  • You can control whether a function/method is accessible outside of the CFC or not by using the access argument on the cffunction line:
    • access="private" will make the function only available within the CFC so it can't be called from outside.
    • access="public" will make the function available to outside pages and other CFCs.
    • access="remote" will make the function available to outside pages, other CFCs and via remote applications through a web services interface (WSDL); you need to use this one if you want to make it available to Flash or Flex applications, etc.
    • access="package" will make the function available to other CFCs that extend it or are in the same code archive (called a "package").
  • You can control how variables are accessed within or from outside the CFC:
    • Any variables you set to the this scope are available outside of the CFC and as a result can conflict with other instances of your CFC! Watch out for this one!
    • If you want a variable local to only the function/method, use the var scope, e.g.
      <cfset var.widget = 'blue' />
      Note that you need to do this for loop counters too.
    • If you want to be able to access the variable from anywhere within the current instance of your CFC use either the variables scope or don't define a scope at all; for accuracy sake I recommend assigning everything to the variables scope if it doesn't fit one of the other criteria above.

Happy coding!

Web page attachments - download vs inline with ColdFusion


Here's a quick tip that'll help make life easier for anyone who's trying to use ColdFusion's CFCONTENT tag to send content to the browser. When you're sending a file to the web browser using CFCONTENT you can do it either as an inline file, i.e. the browser will probably try to display it, or you can send it as a file to be downloaded. The only problem is that to do the latter you can't do it with just the CFCONTENT tag, you first need to tell the browser that you're sending a file and then send it, for example:
To pop open the magic Save As dialog in the browser you need to send the Content-disposition HTTP header and tell it you're sending an attached file, along with the filename. Easy when you know how.


Subscribe to Tips &#039;n Tricks