<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kevin Bedell on Internet Tech &#187; ruby on rails</title>
	<atom:link href="http://www.kbedell.com/category/ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kbedell.com</link>
	<description>Discussions on Ruby on Rails, Agile Development and the Boston Tech Scene.</description>
	<lastBuildDate>Mon, 09 Jan 2012 15:40:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Securing Cloud-Based Ruby on Rails Applications: Why I like Engine Yard.</title>
		<link>http://www.kbedell.com/2011/06/22/securing-cloud-based-ruby-on-rails-applications-why-i-like-engine-yard/</link>
		<comments>http://www.kbedell.com/2011/06/22/securing-cloud-based-ruby-on-rails-applications-why-i-like-engine-yard/#comments</comments>
		<pubDate>Wed, 22 Jun 2011 13:22:15 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[aws-ec2]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[leanstartup]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[engine yard]]></category>

		<guid isPermaLink="false">http://www.kbedell.com/?p=364</guid>
		<description><![CDATA[A customer of mine referred me to an article on Cloud Deployment on Amazon Web Services&#8217; EC2 platform that discussed common security holes users are leaving in their instances. The article, Amazon&#8217;s Cloud is Full of Holes, warned that poor practices by AWS users were leaving their applications ripe for attack. I completely understand the [...]]]></description>
			<content:encoded><![CDATA[<p>A customer of mine referred me to an article on Cloud Deployment on Amazon Web Services&#8217; EC2  platform that discussed common security holes users are leaving in their instances. The article, <a href=" http://www.itworld.com/security/175927/researchers-aws-users-are-leaving-security-holes">Amazon&#8217;s Cloud is Full of Holes</a>, warned that poor practices by AWS users were leaving their applications ripe for attack.</p>
<p>I completely understand the issues behind the story and I agree &#8212; it&#8217;s much easier to create a new instance on AWS than it is to understand how secure it is. A lot of people have the skills to create instances; fewer have the skills to ensure they&#8217;re secure.</p>
<p>This, by the way, is one of the reasons I really like deploying Rails applications on <a href="http://www.engineyard.com/">Engine Yard</a>.</p>
<p>When you create an instance on <a href="http://www.engineyard.com/">Engine Yard</a>, here are some of the security features you get:</p>
<ul>
<li>It&#8217;s impossible to &#8216;ssh&#8217; directly into a system with a username/password. &#8216;ssh keys&#8217; are required.</li>
<li>You can only connect to the machines as the &#8216;deploy&#8217; user &#8212; not as root or any other user.</li>
<li>Once you login, you have sudo access and can swith user to root, but only after you&#8217;re on the machine already.</li>
<li>To enable &#8216;ssh&#8217; connection for a particular user, you have to log into the Engine Yard admin panel and upload the user&#8217;s public key then specifically authorize them on a particular instance.</li>
<li>The apps in the stack (passenger, rails, mysql, postgresql, etc) are run under accounts with restricted access.</li>
<li>The database passwords only exist on the instance and are generated random strings.</li>
</ul>
<p>This isn&#8217;t to say that they&#8217;re perfect, but I think it does say that a good deal of care has been taken to make sure the instances are secure. Most of the examples in the article were from users who were inexperienced or lacked the knowledge to secure their instances. </p>
<p>I once worked with another customer who deployed their applications using a different (yet commonly used) deployment tool. It created their instances using one of the popular Ubuntu-based AMI&#8217;s. </p>
<p>There were a number of security issues with the implementation &#8212; primary access to the instances was done using &#8216;ssh&#8217; with &#8216;root&#8217; as the login, the database accounts were setup with no passwords, etc. Not that the tool they used didn&#8217;t allow these things, but they took extra time to implement and the person who&#8217;d set it up hadn&#8217;t done so.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kbedell.com/2011/06/22/securing-cloud-based-ruby-on-rails-applications-why-i-like-engine-yard/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JQuery-UI verus SimpleForm for Rails Forms processing</title>
		<link>http://www.kbedell.com/2011/06/21/jquery-ui-verus-simpleform-for-rails-forms-processing/</link>
		<comments>http://www.kbedell.com/2011/06/21/jquery-ui-verus-simpleform-for-rails-forms-processing/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 16:01:31 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://www.kbedell.com/?p=359</guid>
		<description><![CDATA[Recently, I had a conversation with a colleague about using JQuery UI to layout form processing for a Ruby on Rails application. I cautioned them against it. In general, I&#8217;ve found more success using the simple_form library for generating form processing. I&#8217;m a huge fan of JQuery itself and use it a lot, but I [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I had a conversation with a colleague about using<a href="http://jqueryui.com/"> JQuery UI</a> to layout form processing for a Ruby on Rails application. I cautioned them against it.</p>
<p>In general, I&#8217;ve found more success using the simple_form library for generating form processing. I&#8217;m a huge fan of <a href="http://jquery.com/">JQuery</a> itself and use it a lot, but I find JQuery UI to be less valuable. It seems over-engineered for what people use it for. </p>
<p>What I&#8217;ve found with JQuery UI sometimes is that people use it because it promises a lot of capability with not very much coding effort. But the challenge comes when there is debugging to do or when you want functionality that is not &#8216;out of the box&#8217;. </p>
<p>I had a customer very recently that brought me in to address some issues getting a complicated form to work on a project that used a lot of JQuery UI components. They had used these components and then tried to extend them because the functionality they wanted wasn&#8217;t exactly &#8216;out of the box&#8217;. It ended up being very complicated to debug and it took me close to a day to trace one of the defects back into the JQuery UI component itself &#8212; it was placing random extra elements in the DOM on the browser and causing some things to not work.</p>
<p>Debugging complicated JavaScript issues in the browser is more complicated than tracing rails exceptions on the server side.</p>
<p><a href="https://github.com/plataformatec/simple_form">simple_form</a>, on the other hand, is a much simpler framework to use. Basically the views are very simple and styling and layout is determined through css. If you need any dynamic features on the form you can implement them using straight JQuery &#8212; which gives you a wealth of capability. Trying to add JQuery functions on top of JQuery UI components is much more complicated to debug.</p>
<p>Here&#8217;s a <a href=" http://railscasts.com/episodes/234-simple-form">railscast</a> on &#8216;simple_form&#8217; &#8211; that&#8217;s a good place to start. It&#8217;s getting to become the most widely accepted way to do form processing for rails.</p>
<p>All this being said, using JQuery UI for to implement components of a view that aren&#8217;t related to forms processing may be the best way to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kbedell.com/2011/06/21/jquery-ui-verus-simpleform-for-rails-forms-processing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How To Get Started with Ruby on Rails &#8212; Where should you start?</title>
		<link>http://www.kbedell.com/2011/06/06/getting-started-with-ruby-on-rails-where-should-you-start/</link>
		<comments>http://www.kbedell.com/2011/06/06/getting-started-with-ruby-on-rails-where-should-you-start/#comments</comments>
		<pubDate>Mon, 06 Jun 2011 14:44:17 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[agile]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://www.kbedell.com/?p=353</guid>
		<description><![CDATA[A friend of mine is beginning an effort to learn Ruby on Rails. He asked me where to start and I sent him a few links that I felt covered some of the key components of Rails that were critical to learn first. Not everyone will agree with my choices, but nevertheless this is what [...]]]></description>
			<content:encoded><![CDATA[<p>A friend of mine is beginning an effort to learn Ruby on Rails. He asked me where to start and I sent him a few links that I felt covered some of the key components of Rails that were critical to learn first. Not everyone will agree with my choices, but nevertheless this is what I thought. </p>
<p>I figured I&#8217;d share them here since there may be other people around asking the same questions.</p>
<p>These links are references to the &#8216;guides&#8217; that were developed as documentation by the Rails community. They&#8217;re &#8216;reference guides&#8217;, so they&#8217;re deeper in places than you&#8217;ll need. But I think they&#8217;re useful and I refer to them often.</p>
<p>1. Getting Started. To get started, the first thing is to just build a simple app and get it running. This, if nothing else, verifies that you have everything installed correctly and introduces you to the basics of building a rails application.</p>
<p>link: <a href="http://guides.rubyonrails.org/getting_started.html">Getting Started with Ruby on Rails</a>.</p>
<p>2. ActiveRecord. The first thing you need to understand with Ruby and Rails is how ActiveRecord works. It&#8217;s more than just the interface layer to the database, it&#8217;s the foundation of all your &#8216;Model&#8217; code including data validation and relationships between objects.</p>
<p>Link: <a href="http://guides.rubyonrails.org/active_record_querying.html">Active Record Query Interface</a> </p>
<p>3. Rails routing. Understanding the routing in Rails is something that a lot of beginners miss &#8212; and it makes their first applications sub-optimal. Also, understanding the routing rules makes things so much easier. And it&#8217;s core to understanding the &#8216;restful&#8217; concepts behind rails.</p>
<p>Link: <a href="http://guides.rubyonrails.org/routing.html"> Rails: Routing from the outside in.</a></p>
<p>4. Rendering views. A lot of the magic in rails happens in how easy and flexible it is to build, change and rearrange the actual pages you&#8217;re building &#8212; the &#8216;view&#8217; part of the Mode-View-Controller model that Rails is based on. This guide gives you an introduction to how all that works and what the options are. Notice also how it builds on what you learned in &#8216;Rails Routing&#8217;.</p>
<p>Link: <a href="http://guides.rubyonrails.org/layouts_and_rendering.html">Rails Views: Layouts and Rendering.</a></p>
<p>Don&#8217;t get discouraged and don&#8217;t underestimate &#8212; this is a bit of work. But the value is great. </p>
<p>These guides are build to some extent as &#8216;reference guides&#8217;, so don&#8217;t worry about understanding every line. But scan and read some portions deeply &#8212; and you&#8217;ll come away with a great foundation in what Ruby on Rails is and how it works its magic.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kbedell.com/2011/06/06/getting-started-with-ruby-on-rails-where-should-you-start/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Interview with David Heinemeier Hansson (DHH), Creator of Ruby on Rails.</title>
		<link>http://www.kbedell.com/2011/04/29/interview-with-david-heinemeier-hansson-dhh-creator-of-ruby-on-rails/</link>
		<comments>http://www.kbedell.com/2011/04/29/interview-with-david-heinemeier-hansson-dhh-creator-of-ruby-on-rails/#comments</comments>
		<pubDate>Fri, 29 Apr 2011 16:05:00 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[interview]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[dhh]]></category>

		<guid isPermaLink="false">http://www.kbedell.com/?p=333</guid>
		<description><![CDATA[[This article originally appeared as the cover story Linux Journal Issue #147, published in July of 2006 -- back when I was still just learning Ruby on Rails. -- Kevin Bedell] Kevin: For our readers who are unfamiliar with Ruby and Rails, can you give us a short description of what they are and what [...]]]></description>
			<content:encoded><![CDATA[<p>[This article originally appeared as <a href="http://www.linuxjournal.com/article/8686">the cover story Linux Journal Issue #147</a>, published in July of 2006 -- back when I was still just learning Ruby on Rails. -- Kevin Bedell]</p>
<p><i><b>Kevin: For our readers who are unfamiliar with Ruby and Rails, can you give us a short description of what they are and what makes them different from other development environments?<br />
</b></i></p>
<p>DHH: Ruby is a dynamic and object-oriented programming language created in 1995 by Yukihiro Matsumoto. It has been described as a cross between Smalltalk and Perl, but I don&#8217;t think that juxtaposition does it justice. Ruby is, more than anything else, a language for writing beautiful code that makes programmers happy.</p>
<p>Rails, then, is an attempt to mold the beauty and productiveness of Ruby into a solution for Web applications. We&#8217;ve sought to adhere to the same core principle that guided the development of Ruby: make the programmer happy!</p>
<p>This might all sound mighty fluffy, but only until you recognize that the single-most important factor in programmer productivity is motivation. And, happy programmers are certainly motivated programmers. Thus, if you optimize for happiness, you&#8217;re optimizing for motivation, which ultimately leads to an optimization for productivity.</p>
<p><i><b>Kevin: What is Rails? Why was it developed?</b></i></p>
<p>DHH: Rails is an extraction from a solution to a real problem. It&#8217;s not a science project. It&#8217;s not something clever men sat down and designed in the highest of ivory towers. It&#8217;s simply the generic pieces that were left after I tried to use Ruby to create Basecamp—the Web-based project management system from 37signals.</p>
<p>That means it&#8217;s a very pragmatic, very targeted framework with a strong sense of direction. You might not share its vision, but it undeniably has one. I like to call that opinionated software. And Rails sure has a lot of opinions.</p>
<p>From one point of view, it could be said to be the collection of opinions I have about how Web applications should be constructed. Surely you can use Ruby on Rails without sharing all my opinions on how to create Web applications, but the more opinions you share, the less work is put upon you.</p>
<p>And, these opinions are surprisingly simple. They aim to give most people most of what they want, most of the time. It&#8217;s a strong disagreement with the conventional wisdom that everything should be configurable, that the framework should be impartial and objective. In my mind, that&#8217;s the same as saying that everything should be equally hard.</p>
<p><i><b>Kevin: I&#8217;ve been reading about Active Record and the ORM (Object-Relational Mapping) capabilitites (or how the application interfaces with databases) that are available using Ruby on Rails. Can you comment on this?</b></i></p>
<p>DHH: Active Record has, by many, been called the crown of Rails. Its core mission is to make relational data mesh seamlessly with an object-oriented domain model. And to do so with a minimum of explicit configuration.</p>
<p>So, you&#8217;ll have a Person class that&#8217;s automatically mapped to a people table (notice the cases and pluralization that Rails automatically figures out). This Person class will then have a first_name method if the people table has a first_name column. So, we&#8217;re using reflection and conventions to escape the XML situps that plague frameworks of the old world.</p>
<p>Although the lack of explicit configuration scores high points with the Enterprise crowd used to Hibernate, EJBs and other Java frameworks, it&#8217;s the mere notion of ORM that wins big with the PHP/.NET crowd. Active Record relieves you from the vast majority of all SQL writing. It&#8217;s automatically constructed on the fly. No more three-line INSERTs, no more repetitive, tedious UPDATEs. The only SQL left is the bottleneck-clearing work where actual brainpower is involved on how to make this query go really fast.</p>
<p><i><b>Kevin: For many of our readers to adopt Ruby and Rails (or convince their management to let them), they need real success stories. Where has Ruby and Rails been used to build scalable, production applications?<br />
</b></i></p>
<p>DHH: Ruby on Rails has been a huge hit inside a lot of organizations. We have some 400 people signed up as working either partially or completely in a Rails-related job. So, like an iceberg, the bulk of the action happens below the surface.</p>
<p>But, we do have a good number of public success stories too. My own company, 37signals, has four widely popular applications used by hundreds of thousands to manage their projects (Basecamp), their personal life (Backpack), their to-do lists (Ta-Da List) and their collaborative writing (Writeboard). That suite has been the number-one poster child for Ruby on Rails and has helped win over a lot of doubters.</p>
<p>But 37signals is by no means the only small team doing big things with Ruby on Rails. The Robot Co-op has a suite of social networks that includes 43things, 43places and 43people. Together, these networks push more than two and a half million dynamic page views a day across their three-machine setup.</p>
<p>Odeo is running Ruby on Rails to power its podcasting portal in front of thousands of subscribers. Evan Williams created Blogger and knows a thing or two about running a huge, public site. He&#8217;s at the wheel at Odeo.</p>
<p>Strongspace is just one of several Rails applications in the making from TextDrive. They provide gigabytes of secure hosting in the sky. It&#8217;s a really cool and smooth site by the same guys that carry the title of being the official Rails hosting firm.</p>
<p>And, that&#8217;s just a small taste. We have major applications in everything from e-commerce to productivity to content—you name it. There are very few kinds of Web applications left that Rails hasn&#8217;t been used to create.</p>
<p><i><b>Kevin: By the way, I&#8217;ve been a Backpack user for a while and I love it. Was it completely developed using Rails?</b></i></p>
<p>DHH: Backpack is indeed 100% Ruby on Rails. When it launched, it was a mere 2,000 lines of code.</p>
<p><i><b>Kevin: Java had been around for a while before it really penetrated the enterprise. It took the development of J2EE for it to establish itself as a true “enterprise development platform”. The addition of transactional management, flexible deployment strategies and so on seemed required for it to mature into that role. Could you see Ruby and Rails eventually following a similar path, or do you think its role will be something different?</b></i></p>
<p>DHH: We have a wide enterprise audience that uses Rails simply because it gets the job done, faster. I think we&#8217;ve seen the peak of Java in the enterprise. I&#8217;m sensing an understanding that while Java and the J2EE gang certainly has its uses in legacy integration, huge distributed setups that require two-phase commits and so on, it&#8217;s way overkill for the majority of applications created in the enterprise.</p>
<p>Dave Thomas from the Pragmatic Programmers recently expressed this as “cracking nuts with a sledgehammer”. Yes, a few special jobs do need sledgehammers. But you don&#8217;t need to use it [a sledgehammer] for all the other jobs that need to get done.</p>
<p>That&#8217;s why having a company standard on something like Java and J2EE seems so nonsensical. Why would you use the heaviest and slowest machinery to solve the 80% of the business that would rather have its valuable software two, three, five or ten times faster? Or, whatever the multiplier is in your environment. So, keep the big guns in store for that last 20% that actually requires it.</p>
<p><i><b>Kevin: Is there anything else you think is important to tell our readers about Ruby and Rails?</b></i></p>
<p>DHH: Give it a try! We&#8217;ve fought hard to make Ruby on Rails the easiest Web-application framework to try out. Get Ruby, get RubyGems (the apt-get of Ruby libraries), gem install rails, rails my_application, and you have your application skeleton running and ready to produce.</p>
<p>It&#8217;s hard to relay in words just how fast and easy it is to get started. So, I would invite your readers to check out the 15-minute video on the Rails Web site where we build a complete, if simple, blogging engine. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.kbedell.com/2011/04/29/interview-with-david-heinemeier-hansson-dhh-creator-of-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>BarCamp Boston 6, April 9-10, 2011 Cambridge, MA</title>
		<link>http://www.kbedell.com/2011/03/22/barcamp-boston-6-april-9-10-2011-cambridge-ma/</link>
		<comments>http://www.kbedell.com/2011/03/22/barcamp-boston-6-april-9-10-2011-cambridge-ma/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 20:43:37 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[career]]></category>
		<category><![CDATA[leanstartup]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://www.kbedell.com/?p=325</guid>
		<description><![CDATA[Make sure you don&#8217;t miss one of the best tech events of the year in the Boston Area: Barcamp Boston 6, April 9-10 in Cambridge, MA. From the site: &#8220;BarCamp Boston is Boston&#8217;s geek unconference, organized on the fly by attendees, for attendees. Visit the website and wiki at BarCampBoston.org. There is no registration fee, [...]]]></description>
			<content:encoded><![CDATA[<p>Make sure you don&#8217;t miss one of the best tech events of the year in the Boston Area: Barcamp Boston 6, April 9-10 in Cambridge, MA.</p>
<p>From the site:</p>
<p>&#8220;BarCamp Boston is Boston&#8217;s geek unconference, organized on the fly by attendees, for attendees. Visit the website and wiki at BarCampBoston.org. There is no registration fee, and all attendees are equal&#8230; but you don&#8217;t just attend a BarCamp &#8212; you can participate in discussions, host a session of your own, or join in another cooperative event (startup founder match, programming contest, design competition, and more&#8230;).&#8221;</p>
<p>Link:  <a href="http://plancast.com/p/4co9">BarCamp Boston 6 at 1 Memorial Drive, Cambridge, MA &#8211; Conferences,seminars on Plancast</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kbedell.com/2011/03/22/barcamp-boston-6-april-9-10-2011-cambridge-ma/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Example code for storing environment-specific configuration variables in rails</title>
		<link>http://www.kbedell.com/2011/03/17/example-code-for-storing-environment-specific-configuration-variables-in-rails/</link>
		<comments>http://www.kbedell.com/2011/03/17/example-code-for-storing-environment-specific-configuration-variables-in-rails/#comments</comments>
		<pubDate>Thu, 17 Mar 2011 18:39:54 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[rails.env]]></category>

		<guid isPermaLink="false">http://www.kbedell.com/?p=315</guid>
		<description><![CDATA[Here&#8217;s some example code I&#8217;ve used for storing configuration variables using Ruby on Rails. This code allows for defaults as well, so you only have to specify variables per environment if they override the default value. This first file should be put in /lib/app_config.rb. # This singleton class stores configuration options. # It makes use [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s some example code I&#8217;ve used for storing configuration variables using Ruby on Rails. This code allows for defaults as well, so you only have to specify variables per environment <i>if they override the default value</i>.</p>
<p>This first file should be put in <code>/lib/app_config.rb</code>.<br />
<code><br />
# This singleton class stores configuration options.<br />
# It makes use of Ruby's method_missing method<br />
# Any option added to the application's config file<br />
# is automatically available as a method of the same name.<br />
#<br />
class AppConfig<br />
&nbsp;&nbsp;include Singleton</p>
<p>&nbsp;&nbsp;# This file is used to set the configuration options for the application.<br />
&nbsp;&nbsp;CONFIG_FILE = "#{RAILS_ROOT}/config/application.yml"</p>
<p>&nbsp;&nbsp;def initialize<br />
&nbsp;&nbsp;&nbsp;&nbsp;@parser = YamlAppConfigParser.new(CONFIG_FILE)<br />
&nbsp;&nbsp;end</p>
<p>&nbsp;&nbsp;def method_missing(methId)<br />
&nbsp;&nbsp;&nbsp;&nbsp;instance_sym = ("@" + methId.id2name).to_sym<br />
&nbsp;&nbsp;&nbsp;&nbsp;instance_variable_set(instance_sym, @parser.send(methId)) unless &nbsp;&nbsp;&nbsp;&nbsp;instance_variable_get(instance_sym)<br />
&nbsp;&nbsp;&nbsp;&nbsp;instance_variable_get(instance_sym)<br />
&nbsp;&nbsp;end<br />
end<br />
</code></p>
<p>The above code uses <code>method_missing</code> to create methods on the fly that correspond to different configuration variables. Add the config variable, and it automatically becomes available as a method on the AppConfig singleton class.</p>
<p>You need this class to load and parse the yaml file that the data is stored in. It should be in <code>/lib/yaml_app_config_parser.rb</code>.</p>
<p><code><br />
# This class parses /config/application.yml<br />
# It supports both default and environment options.<br />
# Environment options override the default options.<br />
class YamlAppConfigParser</p>
<p>&nbsp;&nbsp;def initialize(yaml_file)<br />
&nbsp;&nbsp;&nbsp;&nbsp;@yaml = YAML.load_file(yaml_file)<br />
&nbsp;&nbsp;end</p>
<p>&nbsp;&nbsp;def method_missing(methId)<br />
&nbsp;&nbsp;&nbsp;&nbsp;if @yaml[RAILS_ENV] &#038;&#038; @yaml[RAILS_ENV][methId.id2name]<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@yaml[RAILS_ENV][methId.id2name]<br />
&nbsp;&nbsp;&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@yaml['default'][methId.id2name]<br />
&nbsp;&nbsp;&nbsp;&nbsp;end<br />
&nbsp;&nbsp;end<br />
end<br />
</code></p>
<p>The above 2 files you just put in your project and forget about. Then, you just add config values to the <code>/config/application.yml</code> file, and they become available config variables that vary by environment.</p>
<p>Here&#8217;s what a basic<code>/config/application.yml</code> might look like.</p>
<p><code><br />
default:<br />
&nbsp;&nbsp;facebook_app_id: adsf78yadfkjasdf807y<br />
&nbsp;&nbsp;facebook_secret: adsf78yadfkjasdf807y<br />
&nbsp;&nbsp;path_to_file_foo: /mnt/files/foo.bar</p>
<p>development:<br />
&nbsp;&nbsp;path_to_file_foo: /User/MyUser/tmp/files/foo.bar</p>
<p>production:<br />
&nbsp;&nbsp;facebook_app_id: my_prod_fb_app_id<br />
&nbsp;&nbsp;facebook_secret:  my_prod_secret<br />
</code></p>
<p>Notice that the production environment has its own <code>facebook_app_id</code> and <code>facebook_secret</code> values, while the development environment just uses the default values. That&#8217;s how this approach works &#8211; you override only what you need.</p>
<p>Now to access these values from your code is simple, you just call:</p>
<p>&nbsp;&nbsp;@facebook_app_id = AppConfig.instance.facebook_app_id<br />
&nbsp;&nbsp;@facebook_secret = AppConfig.instance.facebook_secret<br />
&nbsp;&nbsp;@path_to_file_foo = AppConfig.instance.path_to_file_foo</p>
<p>Then the variables you&#8217;ve set as above contain the configuration values specific to their environment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kbedell.com/2011/03/17/example-code-for-storing-environment-specific-configuration-variables-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to validate an email address using regular expressions</title>
		<link>http://www.kbedell.com/2011/03/16/how-to-validate-an-email-address-using-regular-expressions/</link>
		<comments>http://www.kbedell.com/2011/03/16/how-to-validate-an-email-address-using-regular-expressions/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 13:22:14 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://www.kbedell.com/?p=307</guid>
		<description><![CDATA[Anyone who writes web applications has likely built forms for users to enter their e-mail address. It’s considered a part of our basic identity now &#8211; like our name and address. It’s expected we have them. But then, inevitably, once we’ve collected e-mails from all our customers and we go to use them &#8211; we [...]]]></description>
			<content:encoded><![CDATA[<p>Anyone who writes web applications has likely built forms for users to enter their e-mail address. It’s considered a part of our basic identity now &#8211; like our name and address. It’s expected we have them.</p>
<p>But then, inevitably, once we’ve collected e-mails from all our customers and we go to use them &#8211; we get bounces. Which leaves us to clean up the mess &#8211; and there usually is a mess to clean up if we can’t tell the customer their order is ready or that we need information from them. Worse yet, we might just assume the information got through correctly and go on our merry way &#8211; leaving our customer dangling.</p>
<p>And while we’re quietly cursing our chubby-fingered (yet all important) customers, we wonder (or scream!) to ourselves why we don’t just write some code to validate the e-mail addresses when they’re entered?</p>
<p>But anyone who’s really looked into doing this will tell you that it gets deep quickly. What seems like it should be straightforward ends up arcane and impossible.</p>
<p>To begin with, e-mail address formats are covered by RFC 822 &#8211; which is filled with impenetrable discussions on “sequences of lexical symbols” such as “atoms”, “special characters”, “domain-literals” and “comments”.</p>
<p>“comments”? Yes, e-mail addresses can contain comments. I tested them too &#8211; and they work. A comment is (to the best of my knowledge) any text placed in parentheses anywhere in the email address. For example, my e-mail can be:</p>
<p><code><br />
    * kevin@kbedell.com, or<br />
    * kev(you da man!)in@kbedell.com, or<br />
    * kevin@k(evin)bedell.com<br />
</code></p>
<p>All these work &#8211; I tried them. Try validating that. I dare you.</p>
<p>Another bit of a twist is that you can also specify an IP address instead of a domain name. For example, I’m not only “kevin@kbedell.com”, I’m also kevin@216.80.243.82.</p>
<p>To make matters worse &#8211; as it should be expected to get &#8211; many mail servers won’t accept emails even if they are valid. For example, my mail server won’t accept kevin@216.80.243.82 &#8211; the anti-spam controls bounce it.</p>
<p>Imagine &#8211; all that work to validate it, and it still won’t work. Makes you want to spend your days surfing these pages…</p>
<p>I even ran across one brave soul that came up with a regular expression that he was sure could validate an e-mail address. Here it is:</p>
<p><code><br />
function isValidEmail(emailAddress) {<br />
  var re =<br />
/^(([^<>()[\]\\.,;:\s@\”]+(\.[^<>()[\]\\.,;:\s@\”]+)*)|(\”.+\”))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/<br />
  return re.test(emailAddress);<br />
}<br />
</code></p>
<p>Wow. That’s a mouthful. Of course, I’m so jaded by now that I’m sure he must’ve missed something. Or that the emails will just get bounced anyway.</p>
<p>So is validating an email address impossible? Here’s the answer: It’s easy!</p>
<p>You don’t have to be a genius to validate email addresses. All you have to do is send a test e-mail to the customer! Really &#8211; this is the only way. If it gets through, the address is valid. If it bounces, then it’s not.</p>
<p>Now let’s just hope no one ever changes their email address once we validate it…</p>
<p>Are my points “valid”?</p>
<p>[Note: This is a repost of a <a href="http://www.oreillynet.com/onlamp/blog/2002/12/how_to_validate_an_email_addre.html">post I originally wrote</a> for The O'Reilly Network in December of 2002]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kbedell.com/2011/03/16/how-to-validate-an-email-address-using-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8216;seed&#8217; data versus &#8216;testing&#8217; data (and custom rake tasks) for Ruby on Rails</title>
		<link>http://www.kbedell.com/2011/03/15/seed-data-versus-testing-data-and-custom-rake-tasks-for-ruby-on-rails/</link>
		<comments>http://www.kbedell.com/2011/03/15/seed-data-versus-testing-data-and-custom-rake-tasks-for-ruby-on-rails/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 19:57:20 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[agile]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[rake]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[seed_data]]></category>
		<category><![CDATA[test_data]]></category>

		<guid isPermaLink="false">http://www.kbedell.com/?p=296</guid>
		<description><![CDATA[I&#8217;ve been a part of discussions on how to define &#8216;seed&#8217; data versus &#8216;testing&#8217; data on a Ruby on Rails project. Here&#8217;s a summary of what I&#8217;ve seen work well &#8212; please comment if you have anything to add. Data loading is done for 2 purposes: First, to load data that will seed the system [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been a part of discussions on how to define &#8216;seed&#8217; data versus &#8216;testing&#8217; data on a Ruby on Rails project. Here&#8217;s a summary of what I&#8217;ve seen work well &#8212; please comment if you have anything to add.</p>
<p>Data loading is done for 2 purposes: First, to load data that will seed the system for ongoing use and that will live in the production environment, and second, to use for system testing. These two types of data are stored in two different ways.</p>
<h3>Loading &#8216;seed&#8217; data that will be required in production.</h3>
<p>This data should be defined in <code>/db/seeds.rb</code> and loaded using the <code>rake db:seed</code> command. It should be loaded one time after initial database creation. If changes to the seeds.rb file are made, the database should be rebuilt and reloaded from scratch.</p>
<h3>Loading test data.</h3>
<p>This is data that is required for testing the application. Specifically, it is data that should not appear in the production application. </p>
<p>This data should be loaded through model classes (or using factory_girl or similar) in a &#8216;rake&#8217; file, for example <code>/lib/tasks/test_data.rake</code> and then load it using the rake task <code>rake app:load_demo_data</code>. Similar to loading seeds.rb, if the test data changes then the database should be reloaded from scratch.</p>
<p>(Note that here the rake file is named <code>/lib/tasks/test_data.rake</code> and the rake task to load the data is <code>rake app:load_demo_data</code>. This would vary based on what you felt was an appropriate name for your project.)</p>
<h3>Overall database loading/unloading</h3>
<p>The correct way to load data into the database is to use the following rake commands:</p>
<p>  <code>rake db:drop db:create db:migrate db:seed app:load_demo_data</code></p>
<p>As you see, multiple rake commands can be run one after another sequenced on the same line. </p>
<p>This should be able to be done at any time by any person in development. If you make a change to any data, please assume that the above sequence of rake commands could be run at any time and all data could be replaced. </p>
<p>Note also that the above command will load data into the &#8216;development&#8217; instance of your database. If you need to load (or reload) the production or test environments, then precede this command with the appropriate RAILS_ENV like so:</p>
<p>  <code>RAILS_ENV=test rake db:drop db:create db:migrate db:seed app:load_demo_data</code></p>
<p>Here&#8217;s an example of what the rake file <code>/lib/tasks/test_data.rake</code> might look like:</p>
<p><code><br />
namespace :app do<br />
&nbsp;&nbsp;desc <<-DESC<br />
&nbsp;&nbsp;&nbsp;&nbsp;Load testing data.<br />
&nbsp;&nbsp;&nbsp;&nbsp;Run using the command 'rake app:load_demo_data'<br />
&nbsp;&nbsp;DESC<br />
&nbsp;&nbsp;task :load_demo_data => [:environment] do</p>
<p>&nbsp;&nbsp;# Only data not required in production should be here.<br />
&nbsp;&nbsp;# If it needs to be there in production, it belongs in seeds.rb.</p>
<p>&nbsp;&nbsp;User.delete_all<br />
&nbsp;&nbsp;Category.delete_all</p>
<p>&nbsp;&nbsp;User.create(:login => "test_user",  :password => "testpass")<br />
&nbsp;&nbsp;Category.create(:category => 'Category #1')</p>
<p>&nbsp;&nbsp;# Other test data should be added here...</p>
<p>&nbsp;&nbsp;end<br />
end<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kbedell.com/2011/03/15/seed-data-versus-testing-data-and-custom-rake-tasks-for-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Top 10 Best Resources to learn Ruby on Rails</title>
		<link>http://www.kbedell.com/2011/02/10/top-10-best-resources-to-learn-ruby-on-rails/</link>
		<comments>http://www.kbedell.com/2011/02/10/top-10-best-resources-to-learn-ruby-on-rails/#comments</comments>
		<pubDate>Thu, 10 Feb 2011 16:28:08 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[lists]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://www.kbedell.com/?p=257</guid>
		<description><![CDATA[I have a lot of people ask me about resources to help them learn and come up to speed on rails. I found this list of resources on Quora recently and thought it was worth reposting here to give it a wider audience. I&#8217;ve also annotated the list a bit to say something about each [...]]]></description>
			<content:encoded><![CDATA[<p>I have a lot of people ask me about resources to help them learn and come up to speed on rails. I found this list of resources on Quora recently and thought it was worth reposting here to give it a wider audience. I&#8217;ve also annotated the list a bit to say something about each entry.</p>
<p><a href="http://mislav.uniqpath.com/poignant-guide/">Why&#8217;s (Poignant) Guide to Ruby</a></p>
<p>Why&#8217;s (Poignant) Guide to Ruby is a classic. It&#8217;s done in an the format of a graphic novel and contains a lot of fun and interesting material. It was done by <a href="http://en.wikipedia.org/wiki/Why_the_lucky_stiff">Why the Lucky Stiff</a>, a cult figure in the ruby community that you should know about.</p>
<p><a href="http://www.railsforzombies.com">Rails for Zombies</a> by EnvyLabs</p>
<p>A fun and entertaining guide to ruby on rails. Be careful, you may find yourself craving brains and entrails for lunch if you finish this one &#8212; though your rails skills will be better off for the effort.</p>
<p><a href="http://www.tryruby.org">Try Ruby!</a></p>
<p>An easy to use place to begin learning about Ruby (Not so much about rails, tho). It&#8217;s a great place to start if you are literally starting from scratch. </p>
<p><a href="http://railstutorial.org/">Ruby on Rails Tutorial </a></p>
<p>This is a non-free resource, but is well done and may be worth investing in if you are serious about learning the material. Highly recommended.</p>
<p><a href="http://rubykoans.com">Ruby Koans </a></p>
<p>Ruby Koans is an interesting and insightful set of lessons on Ruby (not rails) that focuses on teaching through a set of unit tests. One of it&#8217;s strengths is that it introduces you immediately to the value and practice of unit testing &#8212; a critical skill and a core value of the ruby community.</p>
<p><a href="http://api.rubyonrails.org">The Rails API Docs</a></p>
<p>If you&#8217;re going to be a rails programmer, you need to have this url handy. Have a question on the <code>:belongs_to</code> statement? Want to understand the call-back lifecycle for active record model classes? It&#8217;s all here. Not for beginners, but definitely required before you&#8217;re ready to call yourself a master.</p>
<p><a href="http://railscasts.com/">Railscasts</a></p>
<p>On of the best and one of my favorite resources on rails. Railscasts are an important resource for the entire rails community. They are a series of free &#8212; and very useful &#8212; videos on various topics in rails development, complete with source code. Want to know about Ajax calls? Want to understand the latest in authentication libraries? It&#8217;s all here.</p>
<p><a href="http://railsbridge.org/">RailsBridge</a></p>
<p>RailsBridge is an effort to build community around helping people learn rails. It&#8217;s people helping people. You can find a mentor there, get involved with something in your community, learn by volunteering time to a non-profit. It&#8217;s a valuable resource.</p>
<p><a href="http://rubylearning.com">RubyLearning</a></p>
<p>Ruby Learning is a site put together by Satish Talim, a senior software consultant based in Pune, India. He&#8217;s done a thorough job of providing lessons on many aspects of the ruby language. The site is a bit over-done with adsense and other advertising, but there&#8217;s a lot of meat there too.</p>
<p><a href="http://peepcode.com/">Peepcode Screencasts</a></p>
<p>Peepcode Screencasts are another well-known resource in the rails community. Similar to Railscasts, they publish a regular series of videos on different aspects of rails development. The screencasts aren&#8217;t free, but considering the time they could save you they could be a great investment in terms of getting you up to speed fast. They&#8217;re widely known and recommended.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kbedell.com/2011/02/10/top-10-best-resources-to-learn-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>What is the best way to structure a revenue share with programmers or developers for application development?</title>
		<link>http://www.kbedell.com/2011/01/11/what-is-the-best-way-to-structure-a-revenue-share-with-programmers-or-developers-for-application-development/</link>
		<comments>http://www.kbedell.com/2011/01/11/what-is-the-best-way-to-structure-a-revenue-share-with-programmers-or-developers-for-application-development/#comments</comments>
		<pubDate>Tue, 11 Jan 2011 17:15:56 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[leanstartup]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://www.kbedell.com/?p=247</guid>
		<description><![CDATA[Here&#8217;s the question: &#8220;Developing social and mobile applications can be expensive and risky. Some programmers are willing to reduce or eliminate their fees in exchange for revenue share on the application. What is the best way to structure a deal? If the application doesn&#8217;t earn expected revenues, how can you then remunerate programmers for their [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s the question: &#8220;Developing social and mobile applications can be expensive and risky. Some programmers are willing to reduce or eliminate their fees in exchange for revenue share on the application. What is the best way to structure a deal? If the application doesn&#8217;t earn expected revenues, how can you then remunerate programmers for their work?&#8221;</p>
<p>To begin with, I&#8217;m not sure I agree with the premise of the question, in general.</p>
<p>If you want good solid work and it&#8217;s early, then pay people or make them cofounders.</p>
<p>Offering them a revenue share later (assuming revenue shows up) is problematic for just the reason you&#8217;re asking &#8212; what do you do if the revenue doesn&#8217;t show up?</p>
<p>Trying to find programmers willing to work for a promise of a share of potential revenue is likely to attract only programmers who can&#8217;t get a better deal. In other words, if they were really good they&#8217;d either be co-founding something or getting paid well for their skills.</p>
<p>Bottom line &#8212; either make them &#8216;co-founders&#8217; or pay them. If not, you&#8217;ll increase your potential to attract people with nothing better to work on.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kbedell.com/2011/01/11/what-is-the-best-way-to-structure-a-revenue-share-with-programmers-or-developers-for-application-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

