<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>PCR Web Design Knowledge Base</title>
    <link>http://pcr-webdesign.com</link>
    <description>PCR Web Design Technical Knowledge Base for web developers. Web design and development from Boulder, Colorado</description>
    <language>en-us</language>
    <item>
      <title>Rails InvalidAuthenticityToken and IE9</title>
      <description>&lt;p&gt;There are many documented reasons for getting the InvalidAuthenticityToken exception in a Rails application. However if you are here after searching for the keywords InvalidAuthenticityToken and Internet Explorer 9 or IE9, chances are it's only happening to  you in IE9 and the following solution will save you a lot of headaches. &lt;/p&gt;&lt;p&gt;Hostnames cannot contain an underscore (_). That means it's not a valid character in a subdomain. Most browsers will play along, even older versions of Internet Explorer, but it turns out IE will not. &lt;/p&gt;&lt;p&gt;So there you go, if you have an underscore in your subdomain, get rid of it and your  Invalid Authenticity Token exception will go away as well. I hope you found this post before you pulled your hair out.&lt;/p&gt;</description>
      <author>Pablo Calderon</author>
      <pubDate>Tue, 02 Aug 2011 22:17:00 -0600</pubDate>
      <link>http://www.pcr-webdesign.com/blog/21/rails-invalidauthenticitytoken-and-ie9</link>
      <link>http://www.pcr-webdesign.com/blog/21/rails-invalidauthenticitytoken-and-ie9</link>
    </item>
    <item>
      <title>BabyTriana.com - Create your own online baby book</title>
      <description>&lt;p&gt;We are very excited to announce the last project launched by PCR Web Design. &lt;a href="http://babytriana.com"&gt;BabyTriana.com&lt;/a&gt; is a free resource for parents of babies and small children so they can create a personalized website for them. With minimal effort, in just minutes, parents can create an online baby book. An online baby book is a great tool for parents to share their children development with family and friends. With BabyTriana.com is effortless and safe thanks to BabyTriana's privacy protection and friendly interface.&lt;/p&gt;&lt;p&gt;Some of the features that make &lt;a href="http://babytriana.com"&gt;BabyTriana.com&lt;/a&gt; unique are:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;span class="bold redish"&gt;Great-looking website personalized specifically for your baby&lt;/span&gt;&lt;br /&gt; Choose between a growing number of templates and further personalize your baby book with your own header pictures and content.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span class="bold redish"&gt;Protects your privacy&lt;/span&gt;&lt;br /&gt;You decide who can visit your online baby book. Choose between a public website or a private one where only members authorized by your can access its pages&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span class="bold redish"&gt;Photo and video galleries&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span class="bold redish"&gt;BabyTriana is bilingual&lt;/span&gt;&lt;br /&gt;BabyTriana speaks English and Spanish. Site administrators can opt to display pages in English or Spanish. You can also let visitors select their preferred language.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span class="bold redish"&gt;Integration with Facebook&lt;/span&gt;&lt;br /&gt;BabyTriana plays nice with Facebook. When you publish or update a blog entry or a picture gallery you can post a link to the updated page on your Facebook wall by simply crossing a checkbox. &lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;/p&gt;&lt;p&gt;And many more. Read the complete feature list at &lt;a href="http://babytriana.com/features"&gt;http://babytriana.com/features&lt;/a&gt;&lt;/p&gt;&lt;p&gt;BabyTriana.com is inspired by our daughter Triana. We created a baby website for her and after the encouraging feedback by other parents we decided to share this tool with everyone so all of you parents can enjoy and your babies can have their very own website. &lt;/p&gt;&lt;p&gt;BabyTriana.com is &lt;span class="bold redish"&gt;FREE&lt;/span&gt; for all. &lt;a href="http://babytriana.com"&gt;Start&lt;/a&gt; your baby's online baby book now!&lt;/p&gt;</description>
      <author>Pablo Calderon</author>
      <pubDate>Tue, 26 Apr 2011 06:57:00 -0600</pubDate>
      <link>http://www.pcr-webdesign.com/blog/20/babytriana-com---create-your-own-online-baby-book</link>
      <link>http://www.pcr-webdesign.com/blog/20/babytriana-com---create-your-own-online-baby-book</link>
    </item>
    <item>
      <title>Setting the rails environment in Apache and Nginx</title>
      <description>&lt;p&gt;When you deploy a Rails application using Capistrano the application runs in production mode by default and you don't normally have to worry about it. But what happens when you are taking advantage of Capistrano multistage to set up multiple environments? How do you set the environment your application will run on?&lt;/p&gt;&lt;p&gt;The answer is in the virtual host definition in your web server. In Apache you do:&lt;div class="codeblock"&gt;RailsEnv = staging&lt;/div&gt;&lt;br /&gt;In Nginx is slightly different:&lt;div class="codeblock"&gt;rails_env = staging;&lt;/div&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
      <author>Pablo Calderon</author>
      <pubDate>Mon, 13 Dec 2010 21:35:00 -0700</pubDate>
      <link>http://www.pcr-webdesign.com/blog/19/setting-the-rails-environment-in-apache-and-nginx</link>
      <link>http://www.pcr-webdesign.com/blog/19/setting-the-rails-environment-in-apache-and-nginx</link>
    </item>
    <item>
      <title>Javascript: Roll out your own image panning </title>
      <description>&lt;p&gt;There are some libraries &amp;mdash;including some proprietary ones&amp;mdash; that offer panning functionality. Rolling out your own panning functionality to oversized images on your webpages is actually a fairly simple task and can be achieved by using unobstrusive javascript and CSS without the need of any library. Have I said it's cross-browser compatible?&lt;/p&gt;&lt;p&gt;Basically you'll be wrapping your oversized image in two divs; one with the true dimensions of the image and another one with the available panning area. Use the clip property and set overflow to hidden in the wrapping div to achieve the desired effect.&lt;/p&gt;&lt;p&gt;Your html code will be as simple as this:&lt;br /&gt;&lt;div class="codeblock"&gt;&amp;lt;div class=&amp;quot;pan-container&amp;quot;&amp;gt;&lt;br /&gt;  &amp;lt;div class=&amp;quot;panner&amp;quot; onmousedown=&amp;quot;startDrag(event)&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;img class=&amp;quot;panned&amp;quot; src=&amp;quot;oversized-image.jpg&amp;quot; ondragstart=&amp;quot;return false&amp;quot; onmousedown=&amp;quot;return false&amp;quot; /&amp;gt;&lt;br /&gt;  &amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;br /&gt;And now your CSS:&lt;br /&gt;&lt;div class="codeblock"&gt;.pan-container{&lt;br /&gt;  width: 300px; height: 300px;&lt;br /&gt;  clip: rect(0 300px 300px 0);&lt;br /&gt;  position: relative;&lt;br /&gt;  overflow:hidden;&lt;br /&gt;}&lt;br /&gt;.panner {&lt;br /&gt;  position:relative;&lt;br /&gt;  width: 1000px; height: 1000px;&lt;br /&gt;}&lt;/div&gt;&lt;br /&gt;The trick in the javascript code is to use the top and left properties of the first div (panner) to move the image around. Get a little fancy and cap the top and left properties so the image can't be panned out of its margins. This limits can be calculated from the clientHeight and clientWidth properties of the surroundings div. &lt;/p&gt;&lt;p&gt;A complete implementation of the javascript code can be found at &lt;a href="http://pcr-webdesign.com/javascripts/pan.js"&gt;pan.js&lt;/a&gt; which is demonstrated at &lt;a href="http://pcr-webdesign.com/demo/panning"&gt;panning demo&lt;/a&gt;. If you are curious about the used image, it is the Giralda, the bell tower of the Cathedral on Sevilla in Spain. &lt;a href="http://en.wikipedia.org/wiki/Giralda"&gt;http://en.wikipedia.org/wiki/Giralda&lt;/a&gt;&lt;/p&gt;&lt;p&gt;I hope you find it useful.&lt;/p&gt;</description>
      <author>Pablo Calderon</author>
      <pubDate>Sun, 19 Sep 2010 19:09:00 -0600</pubDate>
      <link>http://www.pcr-webdesign.com/blog/17/javascript-roll-out-your-own-image-panning</link>
      <link>http://www.pcr-webdesign.com/blog/17/javascript-roll-out-your-own-image-panning</link>
    </item>
    <item>
      <title>Ruby: obtaining video metadata with ffmpeg</title>
      <description>&lt;p&gt;If you are dealing with videos in your application as opposed to use some online service such as brightcove you are probably familiar with ffmpeg. Have you ever had to use it to obtain meta data about video files in your Ruby/Rails application? &lt;/p&gt;&lt;p&gt;I have done some search online and I have found suggestions for PHP but nothing using Ruby. Naturally you can do it with Ruby code, and it's not terribly complicated, but you need to know a couple of tricks.&lt;/p&gt;&lt;p&gt;Let's suppose you have a video in some format and you need to obtain its duration, width and height. This is all you need to do: &lt;/p&gt;&lt;p&gt;&lt;div class="codeblock"&gt;cmd = &amp;quot;ffmpeg -i #{video_file_path} 2&amp;gt;&amp;amp;1&amp;quot;&lt;br /&gt;output = %x[#{cmd}]&lt;br /&gt;output.match(/Duration: (\d{2,}):(\d{2}):(\d{2}).\d{2},/&lt;br /&gt;secs = $3.to_i + $2.to_i*60 + $1.to_i.3600&lt;br /&gt;output.match(/(\d{3,})x(\d{3,}),/&lt;br /&gt;width = $1.to_i&lt;br /&gt;height = $2.to_i&lt;/div&gt;&lt;br /&gt;Basically you are counting on the fact that the output of ffmpeg has a standardized format that you can parse. First you make sure all the output from your system command is read into the variable output and second you apply some regular expression magic to read the values of interest. You can apply this technique to obtain other meta data as well. &lt;/p&gt;</description>
      <author>Pablo Calderon</author>
      <pubDate>Mon, 16 Aug 2010 21:59:00 -0600</pubDate>
      <link>http://www.pcr-webdesign.com/blog/16/ruby-obtaining-video-metadata-with-ffmpeg</link>
      <link>http://www.pcr-webdesign.com/blog/16/ruby-obtaining-video-metadata-with-ffmpeg</link>
    </item>
    <item>
      <title>PCR Web Design and Four Peas Consulting announce LeaguePortal.com</title>
      <description>&lt;p&gt;PCR Web Design and &lt;a href="http://www.fourpeasconsulting.com"&gt;&lt;/a&gt; Four Peas Consulting announce a partnership to develop and market &lt;a href="https://leagueportal.com"&gt;LeaguePortal.com&lt;/a&gt;, a sports league and team management website. LeaguePortal.com simplifies administration of recreational and competitive sports leagues. By combining league management and team management functionality into a seamless interface, league managers can manage multiple divisions from a single home screen. For league managers, communicating with coaches/team managers, scheduling games, updating scores and statistics and identifying available referees becomes much easier and less time consuming. Coaches and team managers can communicate directly with the team through a single team page. Individual team members can update each other and the coaches to share team information. LeaguePortal.com is where sports leagues and teams come together seamlessly. &lt;/p&gt;</description>
      <author>Calvin Marshall</author>
      <pubDate>Wed, 11 Aug 2010 18:06:00 -0600</pubDate>
      <link>http://www.pcr-webdesign.com/blog/18/pcr-web-design-and-four-peas-consulting-announce-leagueportal-com</link>
      <link>http://www.pcr-webdesign.com/blog/18/pcr-web-design-and-four-peas-consulting-announce-leagueportal-com</link>
    </item>
    <item>
      <title>Rails Plugin: Controller filters with parameters</title>
      <description>&lt;p&gt;Have you ever wanted to write a controller  before or after filter in Ruby on Rails? It  sure would be nice to be able to do it by passing a append a parameter array to the filter declaration, as you would do, for example, to the ssl_required declaration when using the Ssl_requirement plugin. &lt;/p&gt;&lt;p&gt;Unfortunately such a convenient syntax is missing in Rails, but there are ways to overcome that. &lt;span class="bold redish"&gt;Parameterize_filter&lt;/span&gt; is a minimalist plugin that addresses this missing feature. It adds two methods to controllers:&lt;br /&gt;&lt;li class="bold"&gt;before_filter_with_parameters&lt;/li&gt;&lt;li class="bold"&gt;after_filter_with_parameters&lt;/li&gt;&lt;br /&gt;Now you can declare filters that require arguments like so:&lt;br /&gt;&lt;div class="codeblock"&gt;class MyController &amp;lt; ApplicationController&lt;br /&gt;  before_filter_with_parameters :login_required, Role::ADMIN&lt;br /&gt;  after_filter_with_parameters :log_access, LogLevel::INFO&lt;br /&gt;  # more code...&lt;/div&gt;&lt;br /&gt;&lt;span class="bold redish"&gt;Parameterize_filter&lt;/span&gt; is based on blog comment posted by Cassiano d'Andrea at &lt;a href="http://blog.aclarke.eu/passing-a-parameter-to-a-before-filter/"&gt;http://blog.aclarke.eu/passing-a-parameter-to-a-before-filter&lt;/a&gt;. I merely wrapped it up in a plugin. Parameterize_filter is  an unpretentious plugin but can become very handy when it comes to simplify your controller code. &lt;/p&gt;&lt;p&gt;&lt;span class="bold"&gt;Installation&lt;/span&gt;&lt;br /&gt;Parameterize_filter is hosted at GoogleCode. To install run:&lt;br /&gt;&lt;div class="codeblock"&gt;script/plugin install http://parameterize-filter.googlecode.com/svn/trunk/parameterize_filter&lt;/div&gt;&lt;br /&gt;And you are set to go. Hope you find it useful.&lt;/p&gt;</description>
      <author>Pablo Calderon</author>
      <pubDate>Sat, 27 Mar 2010 08:17:00 -0600</pubDate>
      <link>http://www.pcr-webdesign.com/blog/15/rails-plugin-controller-filters-with-parameters</link>
      <link>http://www.pcr-webdesign.com/blog/15/rails-plugin-controller-filters-with-parameters</link>
    </item>
    <item>
      <title>Monkey patch rest-open-uri to handle 422 HTTP code response</title>
      <description>&lt;p&gt;Rest-open-uri is a hack of open-uri by Leonard Richardson and Sam Ruby that supports entity-bodies, and HTTP methods other than GET. It makes it easy to build Ruby on Rails clients for REST web services. It is a great solution for cases where ActiveRecordResource is not applicable or is simply overkill. &lt;/p&gt;&lt;p&gt;However Rest-open-uri - like open-uri - has an annoying characteristic in its design. When the response is not in the 2xx range, it raises a OpenUri::HTTPError returning the HTTP status code and message. That would be fine, but doing so it ignores the body of the response if there is one. &lt;/p&gt;&lt;p&gt;I find that when responding with a "422 Unprocessable Entity" in my own web services it is useful to include a body in the response explaining what was wrong with the received entity. In fact Sam and Leonard follow this practice themselves in their book &lt;a href="http://oreilly.com/catalog/9780596529260"&gt;RESTful Web Services&lt;/a&gt;. However they failed to incorporate the ability to read that message in rest-open-uri. &lt;/p&gt;&lt;p&gt;I have created a monkey patch for rest-open-uri that uses a little ruby reflection to make the response body available as a method response of the raised OpenURI::HTTPError when the response code is "422 Unprocessable Entity". If interested, download it from &lt;a href="http://pcr-webdesign.com/open-source/rest-open-uri"&gt;rest-open-uri monkey patch&lt;/a&gt;. It is to be copied to your config/initializers directory. &lt;/p&gt;&lt;p&gt;&lt;span class="bold"&gt;Usage:&lt;/span&gt;&lt;br /&gt;You can now write code like this:&lt;br /&gt;&lt;div class="codeblock"&gt;begin&lt;br /&gt;  response = open(RESOURCE_URI),&lt;br /&gt;                            :method =&amp;gt; :put,&lt;br /&gt;         		          :body =&amp;gt; &amp;quot;param=#{CGI::escape(somevar)}&amp;quot;).read&lt;br /&gt;  # handle response here&lt;br /&gt;rescue OpenURI::HTTPError =&amp;gt; e&lt;br /&gt;  if e.io.first == :unprocessable_entity&lt;br /&gt;    error_message = e.response&lt;br /&gt;    # Handle error message here&lt;br /&gt;end&lt;/div&gt;&lt;br /&gt;As usual, feel free to use and modify as convenient to you. Your feedback is welcome!&lt;/p&gt;</description>
      <author>Pablo Calderon</author>
      <pubDate>Tue, 08 Dec 2009 08:01:00 -0700</pubDate>
      <link>http://www.pcr-webdesign.com/blog/14/monkey-patch-rest-open-uri-to-handle-422-http-code-response</link>
      <link>http://www.pcr-webdesign.com/blog/14/monkey-patch-rest-open-uri-to-handle-422-http-code-response</link>
    </item>
    <item>
      <title>Rails plugin: Encapsulate person id data and validation</title>
      <description>&lt;p&gt;&lt;span class="bold redish"&gt;Acts_as_person&lt;/span&gt; continues the saga of simple convenience Rails model plugins developed by PCR Web Design (see acts_as_address for another example). It extends ActiveRecord::Base to add columns to the annotated model describing a person and worrying about the phone number format validation.  It is also an excellent placeholder to add new convenient methods for a model describing a person. Extend it yourself with additional functionality or stay tuned for enhanced versions of the plugin coming soon.&lt;/p&gt;&lt;p&gt;Acts_as_person uses PostgreSQL multiple table inheritance mechanism to normalize the repetitive person information into its own table, thus encapsulating person data and functionality at the database and application level.&lt;/p&gt;&lt;p&gt;&lt;span class="bold"&gt;Installation:&lt;/span&gt;&lt;br /&gt;To install run&lt;br /&gt;&lt;div class="codeblock"&gt;script/plugin install http://acts_as_person.googlecode.com/svn/trunk/acts_as_person&lt;/div&gt;&lt;br /&gt;&lt;span class="bold"&gt;Usage:&lt;/span&gt;&lt;br /&gt;Generate the migration that creates the base table that annotated models share:&lt;br /&gt;&lt;div class="codeblock"&gt;./script/generate acts_as_address&lt;/div&gt;&lt;br /&gt;After installation ActiveRecord::Base is extended with two methods:&lt;/p&gt;&lt;p&gt;&lt;li&gt;&lt;span class="bold"&gt;acts_as_person:&lt;/span&gt;&lt;/li&gt;It adds columns to the annotated model describing a person (first_name, last_name, initial, email).It admits a hash of options:&lt;br /&gt;&lt;div class="codeblock"&gt;acts_as_person :force_last_name =&amp;gt; true, :force_email =&amp;gt; true&lt;/div&gt;&lt;br /&gt;making those fields optional or mandatory. Default is true for both. &lt;/p&gt;&lt;p&gt;&lt;li&gt;&lt;span class="bold"&gt;has_phone:&lt;/span&gt;&lt;/li&gt;Another convenient method that will add format validation for a phone field. It is not tied to acts_as_person except that it is contained in the same plugin and can be used independently. I admits a hash with one option:&lt;br /&gt;&lt;div class="codeblock"&gt;has_phone :force =&amp;gt; true&lt;/div&gt;&lt;br /&gt;Feel free to use and modify as convenient to you. Your feedback is welcome!&lt;/p&gt;&lt;p&gt;&lt;span class="bold"&gt;Requirements:&lt;/span&gt; As mentioned it uses PostgreSQL multiple inheritance so it requires PostgreSQL.&lt;/p&gt;</description>
      <author>Pablo Calderon</author>
      <pubDate>Sat, 05 Dec 2009 07:57:00 -0700</pubDate>
      <link>http://www.pcr-webdesign.com/blog/13/rails-plugin-encapsulate-person-id-data-and-validation</link>
      <link>http://www.pcr-webdesign.com/blog/13/rails-plugin-encapsulate-person-id-data-and-validation</link>
    </item>
    <item>
      <title>Rails plugin: Encapsulate address data and validation</title>
      <description>&lt;p&gt;&lt;span class="bold boldish"&gt;Acts_as_address&lt;/span&gt;  is a Rails model plugin based on an idea described by Dan Chalk in his book Enterprise Rails. It is a convenience plugin that extends ActiveRecord::Base to add columns to the annotated model describing an address and worrying about zip code and phone number format validation. &lt;/p&gt;&lt;p&gt;It uses PostgreSQL multiple table inheritance mechanism to normalize the repetitive address information into its own table, thus encapsulating address data and functionality at the database and application level. You can easily extend the plugin with additional functionality and reuse everywhere. &lt;/p&gt;&lt;p&gt;&lt;span class="bold"&gt;Installation:&lt;/span&gt;&lt;br /&gt;To install run&lt;br /&gt;&lt;div class="codeblock"&gt;script/plugin install http://acts-as-address.googlecode.com/svn/trunk/acts_as_address&lt;/div&gt;&lt;br /&gt;&lt;span class="bold"&gt;Usage:&lt;/span&gt;&lt;br /&gt;Generate the migration that creates the base table that annotated models share:&lt;br /&gt;&lt;div class="codeblock"&gt;./script/generate acts_as_address&lt;/div&gt;&lt;br /&gt;After installation ActiveRecord::Base is extended with two methods:&lt;/p&gt;&lt;p&gt;&lt;li&gt;&lt;span class="bold"&gt;act_as_address&lt;/span&gt;:&lt;/li&gt; It adds columns to the annotated model describing an address (line1, line2, city, state, zip_code, and phone number). It admits a hash of options:&lt;br /&gt;&lt;div class="codeblock"&gt;acts_as_address :force_street =&amp;gt; false, :force_phone =&amp;gt; false&lt;/div&gt;&lt;br /&gt;making those fields optional or mandatory.&lt;/p&gt;&lt;p&gt;&lt;li&gt;&lt;span class="bold"&gt;has_url&lt;/span&gt;:&lt;/li&gt; Another convenient method that will add format validation for a url field whose name is customizable. This field does not exist in the underlying table and you must add it yourself. It is not tied to acts_as_address except that it is contained in the same plugin and can be used independently. It admits a hash of self-descripting options:&lt;br /&gt;&lt;div class="codeblock"&gt;has_url :field_name =&amp;gt; &amp;quot;url-field-name&amp;quot;, :force =&amp;gt; false&lt;/div&gt;&lt;br /&gt;Feel free to use and modify as convenient to you. Your feedback is welcome!&lt;/p&gt;&lt;p&gt;&lt;span class="bold"&gt;Requirements:&lt;/span&gt; As mentioned it uses PostgreSQL multiple inheritance so it requires PostgreSQL. &lt;/p&gt;</description>
      <author>Pablo Calderon</author>
      <pubDate>Thu, 03 Dec 2009 07:37:00 -0700</pubDate>
      <link>http://www.pcr-webdesign.com/blog/11/rails-plugin-encapsulate-address-data-and-validation</link>
      <link>http://www.pcr-webdesign.com/blog/11/rails-plugin-encapsulate-address-data-and-validation</link>
    </item>
  </channel>
</rss>

