<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>RWVHP - Ruby</title>
  <id>tag:www.rwvhp.com,2008:mephisto/ruby</id>
  <generator uri="http://mephistoblog.com" version="0.7.3">Mephisto Noh-Varr</generator>
  <link href="http://www.rwvhp.com/feed/ruby/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://www.rwvhp.com/ruby" rel="alternate" type="text/html"/>
  <updated>2008-03-16T10:09:40Z</updated>
  <entry xml:base="http://www.rwvhp.com/">
    <author>
      <name>shift</name>
    </author>
    <id>tag:www.rwvhp.com,2008-03-09:41</id>
    <published>2008-03-09T23:09:00Z</published>
    <updated>2008-03-16T10:09:40Z</updated>
    <category term="Ruby"/>
    <category term="plugins"/>
    <category term="rails"/>
    <category term="ruby"/>
    <link href="http://www.rwvhp.com/2008/3/9/accessibleformbuilder-usage-and-example" rel="alternate" type="text/html"/>
    <title>AccessibleFormBuilder Usage and Example</title>
<content type="html">
            &lt;p&gt;&lt;a href=&quot;http://github.com/shift/accessible_form_builder/tree/master&quot;&gt;AccessibleFormBuilder&lt;/a&gt; has just been pushed out the door.&lt;/p&gt;


&lt;strong&gt;&lt;span class=&quot;caps&quot;&gt;UPDATE&lt;/span&gt;&lt;/strong&gt; This is the example ;)
&lt;pre&gt;
  &amp;lt;% a_form_for :user, :url =&amp;gt; users_path, :legend =&amp;gt; &quot;Login Details&quot; do |f| %&amp;gt;
    &amp;lt;%= f.text_field :login, :label =&amp;gt; &quot;Username&quot;, :note =&amp;gt; &quot;This is visible to other users&quot;, :required =&amp;gt; true %&amp;gt;
    &amp;lt;%= f.password_field :password, :label =&amp;gt; &quot;Password&quot;, :required =&amp;gt; true %&amp;gt;
    &amp;lt;%= f.password_field :password_confirmation, :label =&amp;gt; &quot;Confirm Password&quot;, :required =&amp;gt; true %&amp;gt;
    &amp;lt;%= f.separator &quot;Personal Details&quot; %&amp;gt;
    &amp;lt;%= f.text_field :firstname, :label =&amp;gt; &quot;First name&quot;, :required =&amp;gt; true %&amp;gt;
    &amp;lt;%= f.text_field :lastname, :label =&amp;gt; &quot;Last name&quot;, :required =&amp;gt; true %&amp;gt;
    &amp;lt;%= f.text_field :email, :label =&amp;gt; &quot;E-Mail&quot;, :required =&amp;gt; true %&amp;gt;
    &amp;lt;%= f.separator &quot;Location Details&quot; %&amp;gt;
    &amp;lt;%= f.text_field :address, :label =&amp;gt; &quot;Location&quot;, :note =&amp;gt; &quot;(eg. New York, 90210, SE1 3SR)&quot;, :required =&amp;gt; true %&amp;gt;
    &amp;lt;%= f.submit &quot;Sign up&quot; %&amp;gt;
  &amp;lt;% end %&amp;gt;
&lt;/pre&gt;

	&lt;p&gt;&lt;strong&gt;&lt;span class=&quot;caps&quot;&gt;UPDATE&lt;/span&gt;&lt;/strong&gt; Added &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt; output&lt;/p&gt;


&lt;pre&gt;
&amp;lt;form action=&quot;/users&quot; class=&quot;aFrm&quot; method=&quot;post&quot;&amp;gt;&amp;lt;div style=&quot;margin:0;padding:0&quot;&amp;gt;&amp;lt;input name=&quot;authenticity_token&quot; type=&quot;hidden&quot; value=&quot;e39d055ff60d1b5388fcf9864ffd1fa568160b9a&quot; /&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;fieldset&amp;gt;&amp;lt;legend&amp;gt;Login Details&amp;lt;/legend&amp;gt;&amp;lt;ol&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;label for=&quot;user_login&quot;&amp;gt;Username:&amp;lt;/label&amp;gt;&amp;lt;input id=&quot;user_login&quot; name=&quot;user[login]&quot; size=&quot;30&quot; type=&quot;text&quot; /&amp;gt;&amp;lt;span class=&quot;requiredField&quot;&amp;gt;*&amp;lt;/span&amp;gt;&amp;lt;em&amp;gt; This is visible to other users&amp;lt;/em&amp;gt;&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;label for=&quot;user_password&quot;&amp;gt;Password:&amp;lt;/label&amp;gt;&amp;lt;input id=&quot;user_password&quot; name=&quot;user[password]&quot; size=&quot;30&quot; type=&quot;password&quot; /&amp;gt;&amp;lt;span class=&quot;requiredField&quot;&amp;gt;*&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;

  &amp;lt;li&amp;gt;&amp;lt;label for=&quot;user_password_confirmation&quot;&amp;gt;Confirm Password:&amp;lt;/label&amp;gt;&amp;lt;input id=&quot;user_password_confirmation&quot; name=&quot;user[password_confirmation]&quot; size=&quot;30&quot; type=&quot;password&quot; /&amp;gt;&amp;lt;span class=&quot;requiredField&quot;&amp;gt;*&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;
      &amp;lt;/ol&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;fieldset&amp;gt;&amp;lt;legend&amp;gt;Personal Details&amp;lt;/legend&amp;gt;
    &amp;lt;ol&amp;gt;

  &amp;lt;li&amp;gt;&amp;lt;label for=&quot;user_firstname&quot;&amp;gt;First name:&amp;lt;/label&amp;gt;&amp;lt;input id=&quot;user_firstname&quot; name=&quot;user[firstname]&quot; size=&quot;30&quot; type=&quot;text&quot; /&amp;gt;&amp;lt;span class=&quot;requiredField&quot;&amp;gt;*&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;

  &amp;lt;li&amp;gt;&amp;lt;label for=&quot;user_lastname&quot;&amp;gt;Last name:&amp;lt;/label&amp;gt;&amp;lt;input id=&quot;user_lastname&quot; name=&quot;user[lastname]&quot; size=&quot;30&quot; type=&quot;text&quot; /&amp;gt;&amp;lt;span class=&quot;requiredField&quot;&amp;gt;*&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;label for=&quot;user_email&quot;&amp;gt;E-Mail:&amp;lt;/label&amp;gt;&amp;lt;input id=&quot;user_email&quot; name=&quot;user[email]&quot; size=&quot;30&quot; type=&quot;text&quot; /&amp;gt;&amp;lt;span class=&quot;requiredField&quot;&amp;gt;*&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;
      &amp;lt;/ol&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;fieldset&amp;gt;&amp;lt;legend&amp;gt;Location Details&amp;lt;/legend&amp;gt;
    &amp;lt;ol&amp;gt;

  &amp;lt;li&amp;gt;&amp;lt;label for=&quot;user_address&quot;&amp;gt;Location:&amp;lt;/label&amp;gt;&amp;lt;input id=&quot;user_address&quot; name=&quot;user[address]&quot; size=&quot;30&quot; type=&quot;text&quot; /&amp;gt;&amp;lt;span class=&quot;requiredField&quot;&amp;gt;*&amp;lt;/span&amp;gt;&amp;lt;em&amp;gt; (eg. New York, 90210, SE1 3SR)&amp;lt;/em&amp;gt;&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;&amp;lt;input name=&quot;commit&quot; type=&quot;submit&quot; value=&quot;Sign up&quot; /&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;/ol&amp;gt;&amp;lt;/fieldset&amp;gt;&amp;lt;/form&amp;gt;
&lt;/pre&gt;
Install with

&lt;pre&gt;
git clone git://github.com/shift/accessible_form_builder.git vendor/plugins/accessible_form_builder
&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://www.rwvhp.com/">
    <author>
      <name>shift</name>
    </author>
    <id>tag:www.rwvhp.com,2008-02-04:22</id>
    <published>2008-02-04T07:41:00Z</published>
    <updated>2008-02-06T08:53:19Z</updated>
    <category term="Ruby"/>
    <category term="mephisto"/>
    <category term="ruby"/>
    <link href="http://www.rwvhp.com/2008/2/4/mephisto-0-8-is-out-with-some-helpfull-additions" rel="alternate" type="text/html"/>
    <title>Mephisto 0.8 is out with some helpful additions</title>
<content type="html">
            &lt;p&gt;The Mephisto team has recently released 0.8 on the way to one point-oh adding&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Switched to will_paginate.&lt;/li&gt;
		&lt;li&gt;Switched from acts_as_attachment to attachment_fu&lt;/li&gt;
		&lt;li&gt;Custom routes&lt;/li&gt;
		&lt;li&gt;Typo and Wordpress converters updates.&lt;/li&gt;
		&lt;li&gt;&lt;span class=&quot;caps&quot;&gt;XML&lt;/span&gt;-RPC interface moved out into a plugin.&lt;/li&gt;
		&lt;li&gt;Multi-site admin interface (shameless plug as I wrote the initial patch).&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Along with more, checkout the change log from git&lt;/p&gt;


&lt;pre&gt;
git clone git://activereload.net/mephisto.git mephisto
cd mephisto; less CHANGELOG
&lt;/pre&gt;

	&lt;p&gt;Happy Blogging.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.rwvhp.com/">
    <author>
      <name>shift</name>
    </author>
    <id>tag:www.rwvhp.com,2007-12-18:5</id>
    <published>2007-12-18T14:49:00Z</published>
    <updated>2008-01-21T09:09:42Z</updated>
    <category term="General Web"/>
    <category term="Ruby"/>
    <category term="gem"/>
    <category term="mojo"/>
    <category term="ruby"/>
    <link href="http://www.rwvhp.com/2007/12/18/i-almost-missed-it" rel="alternate" type="text/html"/>
    <title>I almost missed it</title>
<content type="html">
            &lt;p&gt;&lt;a href=&quot;http://mojo.bt.com&quot;&gt;Mojo&lt;/a&gt; is now in a public beta, if your reading this there is a 99% probability that your in the &lt;a href=&quot;http://www.ruby-lang.org&quot;&gt;Ruby&lt;/a&gt; world so if you want to get started wreaking havoc at work making all of the phones ring you can&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;gem install mojo&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;Congrats to the guys at Mojo for a great job.&lt;/p&gt;


	&lt;p&gt;The following is just to claim the blog on its new &lt;span class=&quot;caps&quot;&gt;URL&lt;/span&gt; with Technorati by linking to my 
&lt;a href=&quot;http://technorati.com/claim/632ik7gv2w&quot;&gt;Technorati Profile&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.rwvhp.com/">
    <author>
      <name>shift</name>
    </author>
    <id>tag:www.rwvhp.com,2007-03-08:14</id>
    <published>2007-03-08T06:44:00Z</published>
    <updated>2008-01-28T06:46:04Z</updated>
    <category term="Ruby"/>
    <category term="ruby"/>
    <category term="zeroconf"/>
    <link href="http://www.rwvhp.com/2007/3/8/avahi-for-discovering-rest-resources" rel="alternate" type="text/html"/>
    <title>Avahi for discovering REST resources</title>
<content type="html">
            &lt;p&gt;Avahi/Zeroconf or Rendezvous as your Mac would know it, can be used in published &lt;span class=&quot;caps&quot;&gt;DNS&lt;/span&gt; records (unicast) as well as the normal &lt;span class=&quot;caps&quot;&gt;LAN&lt;/span&gt; type setup (multicast), its already a standard why don’t we use this for discovering RESTful resources?&lt;/p&gt;


	&lt;p&gt;All this would require would be a service type registered eg. rest.tcp and a flag in the &lt;span class=&quot;caps&quot;&gt;TXT&lt;/span&gt; record naming your resources eg. “resources=/users /articles /articles/comments”.&lt;/p&gt;


	&lt;p&gt;I brought this up (quite randomly) during a talk at my local Ruby Group (ncl.rb).&lt;/p&gt;


	&lt;p&gt;Gimme your feedback?&lt;/p&gt;


	&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;UPDATE&lt;/span&gt; Forgot to add from the initial post use the :resource/new to get an empty object (to_xml or whatever)&lt;/p&gt;


An example of discovering unicast Zeroconf services is
&lt;pre&gt;
shift@carbon:~# avahi-browse -a -d 0pointer.de
+  n/a  n/a Lennart&amp;amp;#8217;s Blog                                _http-rss._tcp       0pointer.de
+  n/a  n/a tango                                         SSH Remote Terminal  0pointer.de
+  n/a  n/a dt115                                         SSH Remote Terminal  0pointer.de
+  n/a  n/a ring2                                         SSH Remote Terminal  0pointer.de
+  n/a  n/a PulseAudio Web Site                           Web Site             0pointer.de
+  n/a  n/a Avahi Web Site                                Web Site             0pointer.de
+  n/a  n/a Lennart's Blog                                Web Site             0pointer.de
+  n/a  n/a Lennart's Photos                              Web Site             0pointer.de
+  n/a  n/a Lennart's Homepage                            Web Site             0pointer.de
&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://www.rwvhp.com/">
    <author>
      <name>shift</name>
    </author>
    <id>tag:www.rwvhp.com,2007-03-07:12</id>
    <published>2007-03-07T06:30:00Z</published>
    <updated>2008-01-28T06:41:56Z</updated>
    <category term="Ruby"/>
    <category term="Work"/>
    <category term="apache"/>
    <category term="mongrel"/>
    <category term="rails"/>
    <category term="ruby"/>
    <link href="http://www.rwvhp.com/2007/3/7/apache-2-2-mongrel" rel="alternate" type="text/html"/>
    <title>Apache 2.2 + Mongrel</title>
<content type="html">
            &lt;p&gt;This isn&#8217;t so much a blog post as somewhere convenient to put some information for ncl.rb.&lt;/p&gt;


	&lt;p&gt;My Apache 2.2 + modproxybalancer virtualhost config&lt;/p&gt;


&lt;pre&gt;
&amp;lt;VirtualHost *:80&amp;gt;
  ServerName yourapp.com
  DocumentRoot /home/web/yourapp.com/current/public/
  &amp;lt;Directory &quot;/home/web/yourapp.com/current/public&quot;&amp;gt;
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  &amp;lt;/Directory&amp;gt;
  # Configure the cluster member proxy
  &amp;lt;Proxy balancer://your_app_cluster&amp;gt;
    BalancerMember http://127.0.0.1:3000
    BalancerMember http://127.0.0.1:3001
    BalancerMember http://127.0.0.1:3002
    BalancerMember http://127.0.0.1:3003
  &amp;lt;/Proxy&amp;gt;
  RewriteEngine On
  # If there is a maintenence.html file in your
  # public dir all requests will get rerouted to
  # this file.  This is for use with capistrano
  RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
  RewriteCond %{SCRIPT_FILENAME} !maintenance.html
  RewriteRule ^.*$ /maintenance.html [L]

  # Rewrite index to check for static index.html
  RewriteRule ^/$ /index.html [QSA]

  # Rewrite to check for Rails cached pages with .html extentions
  RewriteRule ^([^.]+)$ $1.html [QSA]

  # All dynamic requests get sent to the cluster
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule ^/(.*)$ balancer://your_app_cluster%{REQUEST_URI} [P,QSA,L]

  # Deflate for clients that support it.
  AddOutputFilterByType DEFLATE text/html text/plain text/xml
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

  # Error and access logs.
  ErrorLog /var/log/apache/app_error.log
  CustomLog /var/log/apache/app_access.log combined
&amp;lt;/VirtualHost&amp;gt;
&lt;/pre&gt;

	&lt;p&gt;Now if you take the above example it&#8217;ll send all requests to your pack of mongrels, but say you want to have more then one application running on your domain (say beast).&lt;/p&gt;


You&#8217;ll need to create another proxy balancer
&lt;pre&gt;
  &amp;lt;Proxy balancer://your_second_app_cluster&amp;gt;
    BalancerMember http://127.0.0.1:3004
    BalancerMember http://127.0.0.1:3005
    BalancerMember http://127.0.0.1:3006
    BalancerMember http://127.0.0.1:3007
  &amp;lt;/Proxy&amp;gt;
&lt;/pre&gt;
And then add the RewriteRule for it

&lt;pre&gt;
RewriteRule ^/forums/(.*)$ balancer://your_second_app_cluster%{REQUEST_URI} [P,QSA,L]
&lt;/pre&gt;

Now anything going to / that isn&#8217;t /forums/.* will goto yourappcluster and anything with /forums/.* will goto yoursecondapp_cluster
&lt;pre&gt;
&amp;lt;VirtualHost *:80&amp;gt;
  ServerName yourapp.com
  DocumentRoot /home/web/yourapp.com/current/public/
  &amp;lt;Directory &quot;/home/web/yourapp.com/current/public&quot;&amp;gt;
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  &amp;lt;/Directory&amp;gt;
  # Configure the cluster member proxy
  &amp;lt;Proxy balancer://your_app_cluster&amp;gt;
    BalancerMember http://127.0.0.1:3000
    BalancerMember http://127.0.0.1:3001
    BalancerMember http://127.0.0.1:3002
    BalancerMember http://127.0.0.1:3003
  &amp;lt;/Proxy&amp;gt;
  &amp;lt;Proxy balancer://your_second_app_cluster&amp;gt;
    BalancerMember http://127.0.0.1:3004
    BalancerMember http://127.0.0.1:3005
    BalancerMember http://127.0.0.1:3006
    BalancerMember http://127.0.0.1:3007
  &amp;lt;/Proxy&amp;gt;

  RewriteEngine On
  # If there is a maintenence.html file in your
  # public dir all requests will get rerouted to
  # this file.  This is for use with capistrano
  RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
  RewriteCond %{SCRIPT_FILENAME} !maintenance.html
  RewriteRule ^.*$ /maintenance.html [L]

  # Rewrite index to check for static index.html
  RewriteRule ^/$ /index.html [QSA]

  # Rewrite to check for Rails cached pages with .html extentions
  RewriteRule ^([^.]+)$ $1.html [QSA]

  # All dynamic requests get sent to the cluster
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule ^/forums/(.*)$ balancer://your_second_app_cluster%{REQUEST_URI} [P,QSA,L]
  RewriteRule ^/(.*)$ balancer://your_app_cluster%{REQUEST_URI} [P,QSA,L]

  # Deflate for clients that support it.
  AddOutputFilterByType DEFLATE text/html text/plain text/xml
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

  # Error and access logs.
  ErrorLog /var/log/apache/app_error.log
  CustomLog /var/log/apache/app_access.log combined
&amp;lt;/VirtualHost&amp;gt;
&lt;/pre&gt;
yourappcluster mongrel_cluster.yml
&lt;pre&gt;
---
port: &quot;3000&quot; 
environment: production
address: 127.0.0.1
pid_file: log/mongrel.pid
servers: 4

yoursecondappcluster mongrelcluster.yml

---
port: &quot;3004&quot; 
environment: production
address: 127.0.0.1
pid_file: log/mongrel.pid
servers: 4
&lt;/pre&gt;

	&lt;p&gt;Hope that made sense, as its off the top of the head apart from the base apache 2.2 vhost config&lt;/p&gt;


	&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;UPDATE&lt;/span&gt; If your running a Rails app under a path remember to set&lt;/p&gt;


&lt;pre&gt;
ActionController::AbstractRequest.relative_url_root = '/path'
&lt;/pre&gt;

	&lt;p&gt;In your environment.rb or your links will be wrong&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://www.rwvhp.com/">
    <author>
      <name>shift</name>
    </author>
    <id>tag:www.rwvhp.com,2007-02-28:13</id>
    <published>2007-02-28T06:42:00Z</published>
    <updated>2008-02-12T11:34:32Z</updated>
    <category term="Ruby"/>
    <category term="ruby"/>
    <category term="shortcuts"/>
    <link href="http://www.rwvhp.com/2007/2/28/ruby-if-shotcuts" rel="alternate" type="text/html"/>
    <title>Ruby If Shotcuts</title>
<content type="html">
            &lt;p&gt;The if statement, sometimes you don&#8217;t want to type&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;if user.password == user.username
    # do something
  end&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Sometimes you might just want to simply check that the value set isn&#8217;t nil&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;user.password ||= 'default_password'&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Thats the same as writing&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;if user.password == nil
  user.password = 'default_password'
end&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;A slight variation of that would be&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;user.password = params[:password] || 'default_password'&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Which would be the same as&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;if params[:password] != nil
  user.password = params[:password]
else
  user.password = 'default_password'
end&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Theres probably more ways of doing things like this that I haven&#8217;t came across yet, if you know of others leave a comment.&lt;/p&gt;
          </content>  </entry>
</feed>
