<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss version="2.0">
  <channel>
    <title>shiningthrough posts</title>
    <link>http://shiningthrough.co.uk/</link>
    <description>shiningthrough posts</description>
    <language>en-uk</language>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/Shiningthrough" type="application/rss+xml" /><item>
      <title>Install RMagick and ImageMagick on Leopard OS X - Quick and Simple</title>
      <link>http://shiningthrough.co.uk/Install+RMagick+and+ImageMagick+on+Leopard+OS+X+-+Quick+and+Simple</link>
      <description>&lt;p&gt;&lt;a href="http://rmagick.rubyforge.org/" title="RMagick"&gt;RMagick&lt;/a&gt; is a Ruby interface that allows access to the &lt;a href="http://www.imagemagick.org/script/index.php" title="ImageMagick"&gt;ImageMagick&lt;/a&gt; image processing library. When I started out developing in Ruby on Rails, installing RMagick was quite an endeavor, which was one of the reasons I used ImageSciene in preference. The installation has now become very simple indeed.&lt;/p&gt;

&lt;p&gt;Go to the &lt;a href="http://rubyforge.org/frs/?group_id=12&amp;release_id=16101" title="RMagick"&gt;RMagick&lt;/a&gt; download page, and download the rmagick-osx-installer (at the time of writing, this was rm_install-1.2.1.zip)&lt;/p&gt;
&lt;p&gt;Open a terminal window, and enter the following command (Leopard will download RMagick to the Downloads directory, and automatically unzip it there)&lt;/p&gt;
&lt;pre&gt;sudo ruby ~/Downloads/rm_install-1/rm_install.rb&lt;/pre&gt;
&lt;p&gt;And thats it! I was very impressed with its simplicity this time round.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Shiningthrough?a=Dnv7nuYzJG4:UCqtASeK8RE:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Shiningthrough?i=Dnv7nuYzJG4:UCqtASeK8RE:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Shiningthrough?a=Dnv7nuYzJG4:UCqtASeK8RE:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Shiningthrough?i=Dnv7nuYzJG4:UCqtASeK8RE:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <guid>http://shiningthrough.co.uk/Install+RMagick+and+ImageMagick+on+Leopard+OS+X+-+Quick+and+Simple</guid>
    </item>
    <item>
      <title>Install ImageScience on OS X Leopard</title>
      <link>http://shiningthrough.co.uk/Install+ImageScience+on+OS+X+Leopard</link>
      <description>&lt;p&gt;I couldn&amp;rsquo;t find a tutorial that took me through this process successfully, in the end I combined information from several other articles to provide these simple steps.&lt;/p&gt;

&lt;h2&gt;Prerequisites&lt;/h2&gt;
&lt;p&gt;I used a clean fresh Install of Leopard to begin with.&lt;/p&gt;
&lt;p&gt;Make sure you have installed Xcode from the Leopard disk.&lt;/p&gt;

&lt;h2&gt;Install ruby_inline&lt;/h2&gt;
&lt;p&gt;Open a terminal, and enter:&lt;/p&gt;
&lt;pre&gt;sudo gem install RubyInline&lt;/pre&gt;

&lt;h2&gt;Install FreeImage&lt;/h2&gt;
&lt;p&gt;Download FreeImage (http://freeimage.sourceforge.net/download.html)&lt;/p&gt;
&lt;p&gt;Using your editor of choice (I am using Vi), edit Makefile.osx&lt;/p&gt;
&lt;pre&gt;vi ~/Downloads/FreeImage/Makefile.osx&lt;/pre&gt;

&lt;p&gt;to make sure that the following lines read as: (correct for FreeImage 3.11.0)&lt;/p&gt;

&lt;pre&gt;
INCLUDE_PPC = -isysroot /Developer/SDKs/MacOSX10.5.sdk
INCLUDE_I386 = -isysroot /Developer/SDKs/MacOSX10.5.sdk
...
LIBRARIES_PPC = -Wl,-syslibroot /Developer/SDKs/MacOSX10.5.sdk
LIBRARIES_I386 = -Wl,-syslibroot /Developer/SDKs/MacOSX10.5.sdk
&lt;/pre&gt;

&lt;p&gt;then, in a terminal:&lt;/p&gt;

&lt;pre&gt;
cd FreeImage
make
sudo make install
&lt;/pre&gt;

&lt;h2&gt;Install ImageScience&lt;/h2&gt;
&lt;pre&gt;sudo gem install image_science&lt;/pre&gt;

&lt;h2&gt;Test it all worked&lt;/h2&gt;

&lt;pre&gt;
irb
require 'image_science'
&lt;/pre&gt;
&lt;p&gt;It will return true if you have been successful.&lt;/p&gt;

&lt;p&gt;With thanks too&lt;/p&gt;
&lt;a href="http://www.ruby-forum.com/topic/141754" title="www.Ruby-Forum.com"&gt;http://www.ruby-forum.com/topic/141754&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://resettodefault.com/2007/11/05/imagescience_on_leopard" title="www.resettodefault.com"&gt;http://resettodefault.com/2007/11/05/imagescience_on_leopard&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://seattlerb.rubyforge.org/ImageScience.html" title="ImageScience Site"&gt;http://seattlerb.rubyforge.org/ImageScience.html&lt;/a&gt;&lt;br /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Shiningthrough?a=KZa8Je6hqwY:CKg8CNebN1g:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Shiningthrough?i=KZa8Je6hqwY:CKg8CNebN1g:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Shiningthrough?a=KZa8Je6hqwY:CKg8CNebN1g:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Shiningthrough?i=KZa8Je6hqwY:CKg8CNebN1g:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <guid>http://shiningthrough.co.uk/Install+ImageScience+on+OS+X+Leopard</guid>
    </item>
    <item>
      <title>Use Photoshop to remove Mac OS X Leopard window shadows from screenshots</title>
      <link>http://shiningthrough.co.uk/Use+Photoshop+to+remove+Mac+OS+X+Leopard+window+shadows+from+screenshots</link>
      <description>&lt;img alt="OS X Leopard Screenshot without shadows" src="/images/no_shadow.png"/&gt;
&lt;p&gt;Whilst i was writing a recent article it was necessary for me to take some dialog screenshots from OS X Leopard. There are several ways of doing this:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Using the grab utility that comes with OS X.&lt;/li&gt;
	&lt;li&gt;Holding Apple, ctrl, shift and 4, release, then press space.&lt;/li&gt;
	&lt;li&gt;Entering "screencapture -ic" on the command line, then press space. (This appears to be the same capture as above)&lt;/li&gt;
	&lt;li&gt;Use one of the many third party applications available, including &lt;a href="http://projects.digitalwaters.net/index.php?q=instantshot"&gt;InstantShot&lt;/a&gt;, &lt;a href="http://www.ambrosiasw.com/utilities/snapzprox/"&gt;SnapzProX&lt;/a&gt;, &lt;a href="http://www.jingproject.com/"&gt;Jing&lt;/a&gt; and &lt;a href="http://www.yellowmug.com/snapndrag/"&gt;SnapNDrag&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The problem i have with all these is that either they capture the window along with the large drop shadow that Leopard uses, or they capture the window without the drop shadow, but the rounded corners look poor and the edge border is missing&lt;/p&gt;

&lt;p&gt;I have come up with a few Photoshop steps that reconstruct the dialog corners and edges, and also allow you, should you wish, to add a smaller drop shadow back in.&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Take a screen shot, using Apple, ctrl, shift and 4, then pressing space to capture a window.&lt;/li&gt;
	&lt;li&gt;Create a new Photoshop document based on the clipboard, and set the background colour to be white.&lt;/li&gt;
	&lt;li&gt;Paste the screenshot in, it should look something like the dialog above, but with a black background.&lt;/li&gt;
	&lt;li&gt;Using the magic wand tool, with anti-alias switched off, and a tolerance set to 100, select the black region of the image where the shadow would be.&lt;/li&gt;
	&lt;li&gt;Click the "Add layer mask" button to create a mask based on that selection.&lt;/li&gt;
	&lt;li&gt;Adjust the mask as necessary, to make sure only the window is masked.&lt;/li&gt;
	&lt;li&gt;Inverse the mask by pressing Apple and i, to make the shadow masked.&lt;/li&gt;
	&lt;li&gt;Add a layer style to the masked window, select stroke with the following settings: and set the gradient from #7f7f7f to #000000&lt;img alt="OS X Leopard Screenshot without shadows" src="/images/stroke_settings.png"/&gt;&lt;/li&gt;
	&lt;li&gt;Select Inner Shadow with the following settings:&lt;br /&gt;&lt;img alt="Inner Shadow Settings" src="/images/inner_shadow_settings.png"/&gt;&lt;/li&gt;
	&lt;li&gt;And if so desired, select Drop Shadow with the following settings:&lt;br /&gt;&lt;img alt="Drop Shadow Settings" src="/images/drop_shadow_settings.png"/&gt;&lt;/li&gt;
	&lt;li&gt;I have placed these styles in a downloadable layer style &lt;a href="Leopard Window Edge.asl.zip"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Shiningthrough?a=Ili34ltrnr8:ggHqzZtWJ6c:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Shiningthrough?i=Ili34ltrnr8:ggHqzZtWJ6c:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Shiningthrough?a=Ili34ltrnr8:ggHqzZtWJ6c:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Shiningthrough?i=Ili34ltrnr8:ggHqzZtWJ6c:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <guid>http://shiningthrough.co.uk/Use+Photoshop+to+remove+Mac+OS+X+Leopard+window+shadows+from+screenshots</guid>
    </item>
    <item>
      <title>Reindex spotlight in OS X Leopard</title>
      <link>http://shiningthrough.co.uk/Reindex+spotlight+in+OS+X+Leopard</link>
      <description>&lt;p&gt;I recently upgraded to OS x Leopard, and afterwards noticed that spotlight was failing to find certain applications. It was necessary to delete the index database in order to force reindexing. This is done using the mdutil application.&lt;/p&gt;
&lt;p&gt;You can find out what it does by opening a terminal window, and typing:&lt;/p&gt;
&lt;pre&gt;man mdutil&lt;/pre&gt;
&lt;p&gt;But, if you just want to straight ahead and remove the index database, open a terminal window, and type the following:&lt;/p&gt;
&lt;pre&gt;sudo mdutil -E /&lt;/pre&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Shiningthrough?a=jXsiFukYoRQ:9PLMhE_OFvw:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Shiningthrough?i=jXsiFukYoRQ:9PLMhE_OFvw:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Shiningthrough?a=jXsiFukYoRQ:9PLMhE_OFvw:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Shiningthrough?i=jXsiFukYoRQ:9PLMhE_OFvw:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <guid>http://shiningthrough.co.uk/Reindex+spotlight+in+OS+X+Leopard</guid>
    </item>
    <item>
      <title>Safari 3 bugs</title>
      <link>http://shiningthrough.co.uk/Safari+3+bugs</link>
      <description>&lt;p&gt;Like over a million others (at time of writing) i have upgraded to Safari 3. There are some great new features which are covered in other blog posts, but i am also encountering a few problems...&lt;/p&gt;
&lt;p&gt;Apple's new browser crashes on me at least once today, but it is still only a beta, but one problem i found was its lack of support for the pseudo-class, &lt;strong&gt;:last-child&lt;/strong&gt;.&lt;p&gt;
&lt;p&gt;&lt;span class="safari3bug"&gt;First Child &lt;/span&gt;&lt;span class="safari3bug"&gt;Second Child&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The above example when viewed in firefox displays the text "Second Child" in Red, but not in Safari 3 beta.&lt;br /&gt;
	Perhaps its this bug that's causing apple.com's cinema screen page to render incorrectly:&lt;/p&gt;
&lt;img alt="Apple.com broken in Safari 3 Beta" src="/images/safari3_bug.png" /&gt;
&lt;p&gt;Has anyone else noticed any css related deficiencies?&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Shiningthrough?a=qm8zENI_eLo:TPdkF0SM5_0:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Shiningthrough?i=qm8zENI_eLo:TPdkF0SM5_0:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Shiningthrough?a=qm8zENI_eLo:TPdkF0SM5_0:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Shiningthrough?i=qm8zENI_eLo:TPdkF0SM5_0:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <guid>http://shiningthrough.co.uk/Safari+3+bugs</guid>
    </item>
    <item>
      <title>GET and POST in Ruby on Rails</title>
      <link>http://shiningthrough.co.uk/GET+and+POST+in+Ruby+on+Rails</link>
      <description>&lt;p&gt;Lets start with the basics.....&lt;/p&gt;

&lt;h3&gt;What are GET and POST?&lt;/h3&gt;

&lt;p&gt;GET and POST specify the two main ways by which the browser sends a form's data to the server for processing.&lt;/p&gt;

&lt;p&gt;The Get method contacts the server, and sends the forms data in a single transmission step. The browser appends the data to the forms action URL, separated by the question mark character.&lt;/p&gt;

&lt;p&gt;With the POST method, the browser sends the data in two steps. The browser first contacts the server specified in the action attribute, when contact is made the data is sent to the server in a separate transparent transmission.&lt;/p&gt;

&lt;p&gt;How does this fit in with Ruby on Rails? a rails form will process its data by default as a POST unless you specify otherwise:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;%= form_tag({:action =&gt; 'find_holidays_by_country'}, {:method =&gt; 'get'}) %&amp;gt;
&amp;lt;%= end_form_tag %&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Why would you want your form to be a GET? there are many reasons, imagine that a form is used for navigation. After the user has selected their required country, and performed a search, they may want to bookmark the resulting page, this is only possible by use of GET. The following code illustrates this:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;%= form_tag({:action =&gt; 'list_holidays_by_country'}, {:method =&gt; 'get'}) %&amp;gt;
	&amp;lt;%= select_tag(:country, options_from_collection_for_select(@countries, :name, :name)) %&amp;gt;
  	&amp;lt;%= submit_tag 'Search', :name =&gt; nil %&amp;gt;
&amp;lt;%= end_form_tag %&amp;gt;
&lt;/pre&gt;

&lt;p&gt;
Note that select_tag is used as the helper as it is compatible with a GET request, select, and collection_select are not.&lt;br /&gt;Also note that the name of the country is returned in the URL (more meaningful than an id), as well as being used as the text in the select box. See &lt;a href="http://shiningthrough.co.uk/blog/show/6"&gt;here&lt;/a&gt; for more details.&lt;br /&gt;The submit tag is set to nil, so the button does not show up in the URL.
&lt;/p&gt;

&lt;p&gt;For a discussion on which method is most appropriate for a given problem, this is a very useful article &lt;a href ="http://www.w3.org/2001/tag/doc/whenToUseGet.html"&gt;When To Use GET&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lastly a warning when using GET requests. If an action changes the state of something on the server make sure the request is either a POST, or if GET must be used, make sure some kind of human intervention immediately follows.&lt;br /&gt; Search engine spiders, and &lt;a href="http://webaccelerator.google.com/"&gt;web accelerators&lt;/a&gt; follow links, and can cause these actions to trigger unintentionally.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Shiningthrough?a=fr7qaGX2qIQ:_Yd8zS9UuEU:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Shiningthrough?i=fr7qaGX2qIQ:_Yd8zS9UuEU:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Shiningthrough?a=fr7qaGX2qIQ:_Yd8zS9UuEU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Shiningthrough?i=fr7qaGX2qIQ:_Yd8zS9UuEU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <guid>http://shiningthrough.co.uk/GET+and+POST+in+Ruby+on+Rails</guid>
    </item>
    <item>
      <title>Select helper methods in Ruby on Rails</title>
      <link>http://shiningthrough.co.uk/Select+helper+methods+in+Ruby+on+Rails</link>
      <description>&lt;p&gt;It can get quite confusing when it comes to using the different select helpers, &lt;strong&gt;select&lt;/strong&gt;, &lt;strong&gt;select_tag&lt;/strong&gt; and &lt;strong&gt;collection_select&lt;/strong&gt; and in my opinion there is a lack of adequate documentation.&lt;br /&gt; For my own use if nothing more, i have done my best to compare the different form helper methods available, and when and how to use them.&lt;/p&gt;

&lt;p&gt;First we will look at the html for a basic selection box:&lt;/p&gt;
&lt;pre&gt;
&amp;lt;select name="payment"&amp;gt;
&amp;nbsp;&amp;lt;option value="1"&amp;gt;VISA&amp;lt;/option&amp;gt;
&amp;nbsp;&amp;lt;option value="2"&amp;gt;MasterCard&amp;lt;/option&amp;gt;
&amp;nbsp;&amp;lt;option value="3"&amp;gt;Switch&amp;lt;/option&amp;gt;
&amp;lt;/select&amp;gt;
&lt;/pre&gt;
&lt;p&gt;The selection box has some key parts, the name, which is required, and used by the browser when submitting the &amp;lt;select&amp;gt; choices to the server.&lt;/p&gt;

&lt;p&gt;The option tags, each of which are made up from a "value" and "text" pair, the "value" to identify the select item in the server, and the "text" which will be displayed to the user.&lt;/p&gt;

&lt;p&gt;There are three different select form helpers in ruby on rails, "Select", "select_tag" and "collection_select". We will have a closer look at each of them now.&lt;/p&gt;

&lt;h3&gt;&lt;a href="http://www.railsapi.org/select_tag"&gt;select&lt;/a&gt;&lt;/h3&gt;
&lt;small&gt;select(object, method, choices, options = {}, html_options = {})&lt;/small&gt;&lt;br /&gt;
&lt;small&gt;Defined in ActionView::Helpers::FormOptionsHelper&lt;/small&gt;

&lt;p&gt;Use select when you require a basic drop-down selection box populated with data not sourced from a database.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The object is the name of an instance variable. This is typically a model object (singular name of the table whose data you're displaying, or in other words, the table record).&lt;/li&gt;
&lt;li&gt;The method is the attribute of that instance variable. This is typically a field/column of the table whose data you're displaying (really an ActiveRecord method).&lt;/li&gt;
&lt;li&gt;Together the object and method specify the name of the select statement in the generated html&lt;/li&gt;
&lt;li&gt;choices can be any enumerable object e.g arrays and hashes and results of database queries, and contains the option tags for the select box.&lt;/li&gt;
&lt;li&gt;The optional options argument takes various "options" some of which are listed below in the examples.&lt;/li&gt;
&lt;li&gt;The optional html_options argument allows css to be used for styling the select box.&lt;/li&gt;
&lt;li&gt;If one of the option tags in choices matches @object.method, that option tag will be selected&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this example a hash is being used to populate the option tags.&lt;/p&gt;

&lt;pre&gt;
&amp;lt;%= select( "payment", "id", { "Visa" =&amp;gt; "1", "Mastercard" =&amp;gt; "2"}) %&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Select can be used in conjunction with a model object as seen in this example, an instance variable is passed into choices, but is being converted into an array of arrays.&lt;/p&gt;

&lt;pre&gt;
&amp;lt;%= select ("selected_payment", "id", @payments.map {|u| [u.name,u.id]}) %&amp;gt;
&lt;/pre&gt;

&lt;p&gt;The controller may look something like this:&lt;/p&gt;
&lt;pre&gt;
@payments = Payment.find(:all)
@selected_payment = @payments[2]
&lt;/pre&gt;
&lt;p&gt;This will cause the third option_tag to be selected by default in the select box, but collection_select is preferable in this scenario.&lt;/p&gt;

&lt;h3&gt;
&lt;a href="http://www.railsapi.org/actionview-helpers-formtaghelper-select_tag"&gt;select_tag&lt;/a&gt;&lt;/h3&gt;
&lt;small&gt;select_tag(name, option_tags = nil, options = {})&lt;/small&gt;&lt;br /&gt;
&lt;small&gt;Defined in ActionView::Helpers::FormTagHelper&lt;/small&gt;

&lt;p&gt;Use select_tag when you require a drop-down selection box populated with data not sourced from a database, and are happy to hard code the default selected option tag. Select_tag should also be used when you want to process your form as a GET, rather than a POST, see &lt;a href="http://shiningthrough.co.uk/blog/show/7"&gt;here&lt;/a&gt; for more details. Also note that select_tag does not have a html_options parameter&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The name specifies the name of the select statement in the generated html, and is used by the controller to access the selected items. &lt;/li&gt;
&lt;li&gt;The optional option_tags argument is a string containing the option tags for the select box.&lt;/li&gt;
&lt;li&gt;The optional options argument takes various "options" some of which are listed below in the examples.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Simple use of the select_tag helper:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;%= select_tag "payment", "&amp;lt;option&amp;gt;VISA&amp;lt;/option&amp;gt;" %&amp;gt;
&lt;/pre&gt;

&lt;p&gt;In this example, we are using &lt;a href="http://www.railsapi.org/options_for_select"&gt;options_for_select&lt;/a&gt;  which accepts any container and returns a string of option tags, but we have defined an array. Note how the optional second parameter specifies the selected item in the list.&lt;/p&gt;

&lt;pre&gt;
&amp;lt;%= select_tag "payment", options_for_select([ "VISA", "MasterCard", "Switch" ], "MasterCard") %&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Another option is this&lt;/p&gt;

&lt;pre&gt;
&amp;lt;%= select_tag "payment", options_for_select(%w{ VISA Mastercard Switch }) %&amp;gt;
&lt;/pre&gt;

&lt;p&gt;where %w is the shortcut notation for an array of strings that are space separated.&lt;/p&gt;

&lt;p&gt;You can also do multi-select boxes:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;%= select_tag 'payment[]', options_for_select(@payments), :multiple =&amp;gt; true, :size =&amp;gt; 3 %&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Note that the "name" in this case is an array, and @payments is a hash defined in the controller:&lt;/p&gt;
&lt;pre&gt;
@payments = {'Visa' =&gt; 1, 'Mastercard' =&gt; 2, 'Switch' =&gt; 3}
&lt;/pre&gt;
	
&lt;p&gt;We can access the selected payment methods in the controller, using the array:&lt;/p&gt;

&lt;pre&gt;
params[:payment]
&lt;/pre&gt;

&lt;p&gt;select_tag does not support the :prompt option, which may not seem like an issue as we have already shown above how you can select a default option tag. But what if you want your form to GET, not POST, your only option is then to use select_tag, even if your data source is a database.&lt;/p&gt;

&lt;pre&gt;
&amp;lt;%= select_tag(:payment, "&amp;lt;option&amp;gt;-Select a payment method&amp;lt;/option&amp;gt;" + options_from_collection_for_select(@payments, :name, :name)) %&amp;gt;
&lt;/pre&gt;

&lt;p&gt;As select_tag takes a string, we can concatenate an additional string onto the beginning of the parameter, this allows us to add our default option_tag. We use &lt;a href="http://www.railsapi.org/actionview-helpers-formoptionshelper-options_from_collection_for_select"&gt;options_from_collection_for_select&lt;/a&gt; which takes a value_method, and text_method (see collection_select for their definition) and an optional selected_value, and a collection, which can be defined in your controller like this:&lt;/p&gt;

&lt;pre&gt;
@payments = Payment.find(:all, :order=&gt;"name")
&lt;/pre&gt;

&lt;h3&gt;
&lt;a href="http://www.railsapi.org/collection_select"&gt;collection_select&lt;/a&gt;
&lt;/h3&gt;
&lt;small&gt;collection_select(object, method, collection, value_method, text_method, options = {}, html_options = {})&lt;/small&gt;&lt;br /&gt;
&lt;small&gt;Defined in ActionView::Helpers::FormOptionsHelper&lt;/small&gt;

&lt;p&gt;Use collection_select when you require a drop-down selection box, whose source is a model/object&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The object is the singular name of the table whose data you're displaying (the table record).&lt;/li&gt;
&lt;li&gt;The method is the field/column of the the relevant data (really an ActiveRecord method).&lt;/li&gt;
&lt;li&gt;Together the object and method specify the name of the select statement in the generated html &lt;/li&gt;
&lt;li&gt;collection takes the option tags for the select box, this can be a hash or array.&lt;/li&gt;
&lt;li&gt;value_method is the field/column to use for the value of the option tags in your html.&lt;/li&gt;
&lt;li&gt;text_method is the field/column to use for the visible text of the option tags in your html.&lt;/li&gt;
&lt;li&gt;The optional options argument takes various "options" some of which are listed below in the examples.&lt;/li&gt;
&lt;li&gt;The optional html_options argument allows css to be used for styling the select box.&lt;/li&gt;
&lt;li&gt;If one of the option tags in collection matches @object.method, that option tag will be selected&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this example the payment methods are being added to the select box via a model object, notice how we use the option, :prompt to add an additional option tag to the select box, which will be selected by default. Note that if @object.method matches one of the option tags, this will be selected by default, and :prompt wont appear in the list.&lt;/p&gt;
&lt;pre&gt;
&amp;lt;%= collection_select(:payment, :id, @payments, :id, :name, options ={:prompt =&amp;gt; "-Select a payment"}, :class =&amp;gt;"payment") %&amp;gt;
&lt;/pre&gt;

&lt;p&gt;The selected item can be accessed in the controller, by using:&lt;/p&gt;
&lt;pre&gt;
selected_payment = params[payment][id]
&lt;/pre&gt;

&lt;p&gt;A final note: the parameters used in all the helpers may be strings or symbols (symbols may be a better choice in some situations, but that's another article).&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Shiningthrough?a=5Sy4g0vb4gc:EKG_DQVgf-4:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Shiningthrough?i=5Sy4g0vb4gc:EKG_DQVgf-4:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Shiningthrough?a=5Sy4g0vb4gc:EKG_DQVgf-4:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Shiningthrough?i=5Sy4g0vb4gc:EKG_DQVgf-4:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <guid>http://shiningthrough.co.uk/Select+helper+methods+in+Ruby+on+Rails</guid>
    </item>
    <item>
      <title>Simple debugging in ruby on rails</title>
      <link>http://shiningthrough.co.uk/Simple+debugging+in+ruby+on+rails</link>
      <description>&lt;p&gt;I often find while writing a ruby on rails applications that i need to display the contents of a variable quickly and easily, this is straight forward in a view, but not so easy in a controller or model. There are a couple of ways to do this:&lt;p&gt;
&lt;pre&gt;logger.debug "variable"&lt;/pre&gt;
&lt;p&gt;will write to the development.log file, or if your using webrick as your development server, you can use:&lt;p&gt;
&lt;pre&gt;STDERR.puts "variable"&lt;/pre&gt;
&lt;p&gt;and it will show up on the console output where your running your server.&lt;p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Shiningthrough?a=15_JQbZlH2E:K5Q4z4ezSWw:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Shiningthrough?i=15_JQbZlH2E:K5Q4z4ezSWw:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Shiningthrough?a=15_JQbZlH2E:K5Q4z4ezSWw:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Shiningthrough?i=15_JQbZlH2E:K5Q4z4ezSWw:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <guid>http://shiningthrough.co.uk/Simple+debugging+in+ruby+on+rails</guid>
    </item>
    <item>
      <title>My first post!</title>
      <link>http://shiningthrough.co.uk/My+first+post%21</link>
      <description>&lt;p&gt;My first blog post! and i am quite pleased with myself. I wrote this blog application from scratch using Ruby on Rails, its kind of an experiment, i get to try out new features, and generally use this site to mess around with.&lt;P&gt;
&lt;p&gt;In addition the XHTML and CSS that are used to make the layout are also a first for me. You'll notice that the grass always sticks to the bottom of the site, and the page grows from the middle instead of the bottom. This took some time to get working, and is still not 100%.&lt;p&gt;
&lt;p&gt;If you have any issues with the site not working 100% either graphically or functionally, i would really appreciate you letting me know.&lt;p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Shiningthrough?a=TFBv5LWBtTo:R0sBU0E-Xgc:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Shiningthrough?i=TFBv5LWBtTo:R0sBU0E-Xgc:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Shiningthrough?a=TFBv5LWBtTo:R0sBU0E-Xgc:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Shiningthrough?i=TFBv5LWBtTo:R0sBU0E-Xgc:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
      <guid>http://shiningthrough.co.uk/My+first+post%21</guid>
    </item>
  </channel>
</rss>
