Archive for December, 2008

Attachment fu’s “Size is not in the list” problem

Posted in Uncategorized on December 23, 2008 by harryche2008

The fix is to specify :min_size config for has_attachment call:

 has_attachment :content_type => :image,
                 :storage => :file_system,
                 :max_size => 10.megabytes,
         :min_size => 0.kilobytes,
         :resize_to => ‘320×320>’,
                 :thumbnails => { :thumb => ‘126×126>’ }

How to make absolute positioning work correctly

Posted in CSS and Ajax on December 13, 2008 by harryche2008

Absolute position is a very convenient way to align and postion elements within a div section, such as navigation tabs in a header, etc. However, one must remember to specify the containing block’s position property to make it really work.

For example, this is the code for my navigation menus inside a header div, my intention was to put nav tabs at the bottom right of the header box:

<div id="header">
<ul id="nav-tabs">
<li><a href="/">Home</a></li>
<li><a href="/">Page1</a></li>
<li><a href="/">Page2</a></li>
</ul>
</div>

And now my css looks like this:

div#header {
  margin: 0 auto
  width: 900px;
  height: 120px;
  background: url(/images/header-background.gif) repeat-x;
}
ul#nav-tabs {
 position: absolute;
 bottom: 2px; right: 0px;
 height: 41px;
}

Notice I used “position: absolute” for the nav tabs <ul> tag, but it didn’t work, for it showed up at the bottom right of the whole screen, not within just the header.

The fix is to add “position: relative” to the div#header style, then it all works just as expected.

Hope that helps if you have the same problem with absolute positioning.