<?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>[schuchlenz.com] &#187; howto</title>
	<atom:link href="http://www.schuchlenz.com/tag/howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.schuchlenz.com</link>
	<description>posts.each do { &#124;p&#124; read(p) }</description>
	<lastBuildDate>Thu, 25 Feb 2010 13:25:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mailer HOWTO for Rails</title>
		<link>http://www.schuchlenz.com/mailer-howto-for-rails/</link>
		<comments>http://www.schuchlenz.com/mailer-howto-for-rails/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 11:10:01 +0000</pubDate>
		<dc:creator>Stefan Schuchlenz</dc:creator>
				<category><![CDATA[Tech Stuff]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[mailer]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[send]]></category>

		<guid isPermaLink="false">http://www.schuchlenz.com/mailer-howto-for-rails/</guid>
		<description><![CDATA[Since sending mails via Rails is &#8211; at first sight &#8211; a bit tricky, I want to provide you with a quick heads up on how to do that. 
Fortunately Rails provides us with a mailer generator to set up the basics:
ruby script/generate mailer MyMailer
You can of course call it as you like it to [...]]]></description>
			<content:encoded><![CDATA[<p>Since sending mails via <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">Rails</a> is &#8211; at first sight &#8211; a bit tricky, I want to provide you with a quick heads up on how to do that. </p>
<p><span id="more-104"></span><br />Fortunately <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">Rails</a> provides us with a <a href="http://www.schuchlenz.com/tag/mailer/" class="st_tag internal_tag" rel="tag" title="Posts tagged with mailer">mailer</a> generator to set up the basics:</p>
<p><code>ruby script/generate <a href="http://www.schuchlenz.com/tag/mailer/" class="st_tag internal_tag" rel="tag" title="Posts tagged with mailer">mailer</a> MyMailer</code></p>
<p>You can of course call it as you like it to fit your <a href="http://www.schuchlenz.com/tag/application/" class="st_tag internal_tag" rel="tag" title="Posts tagged with application">application</a>. But for this <a href="http://www.schuchlenz.com/tag/howto/" class="st_tag internal_tag" rel="tag" title="Posts tagged with howto">HOWTO</a> let&#8217;s stick to MyMailer. As you have noticed, <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">Rails</a> created some files for us:</p>
<p><code>exists&nbsp; app/models/<br />create&nbsp; app/views/my_mailer<br />exists&nbsp; test/unit/<br />create&nbsp; test/fixtures/my_mailer<br />create&nbsp; app/models/my_mailer.rb<br />create&nbsp; test/unit/my_mailer_test.rb</code></p>
<p>At first, we need to edit app/models/my_mailer.rb and add the following code:</p>
<p><code>def <a href="http://www.schuchlenz.com/tag/mail/" class="st_tag internal_tag" rel="tag" title="Posts tagged with mail">mail</a>(recipient, subject, bodyText)<br />&nbsp; from "no-reply@mydomain.com"<br />&nbsp; recipients recipient<br />&nbsp; subject subject <br />&nbsp; body :bodyText =&gt; bodyText<br />end</code></p>
<p><i><b>Notice: make sure you don&#8217;t use @from or @body &#8211; you maybe won&#8217;t get any error but it simply won&#8217;t work!</b></i><br />This is the function that will be called when we want to <a href="http://www.schuchlenz.com/tag/send/" class="st_tag internal_tag" rel="tag" title="Posts tagged with send">send</a> a <a href="http://www.schuchlenz.com/tag/mail/" class="st_tag internal_tag" rel="tag" title="Posts tagged with mail">mail</a>. You can also use default values (like for the from address) for subject and body if you like. But we want to provide our <a href="http://www.schuchlenz.com/tag/application/" class="st_tag internal_tag" rel="tag" title="Posts tagged with application">application</a> with a form to enter subject and body and to select some recipients (so we have a mass <a href="http://www.schuchlenz.com/tag/mailer/" class="st_tag internal_tag" rel="tag" title="Posts tagged with mailer">mailer</a>, basically). Let&#8217;s edit the <a href="http://www.schuchlenz.com/tag/mail/" class="st_tag internal_tag" rel="tag" title="Posts tagged with mail">mail</a> template &#8211; this is the body of our <a href="http://www.schuchlenz.com/tag/mail/" class="st_tag internal_tag" rel="tag" title="Posts tagged with mail">mail</a> message. It resides in app/views/my_mailer and we call it <a href="http://www.schuchlenz.com/tag/mail/" class="st_tag internal_tag" rel="tag" title="Posts tagged with mail">mail</a>.html.erb (we have to create that). Then we put in:</p>
<p><code>&lt;%= @bodyText %&gt;</code></p>
<p>At the moment, the body text is sufficient, but you can also add a salutation, footer line or whatever you want to be sent alongside the stuff the <a href="http://www.schuchlenz.com/tag/user/" class="st_tag internal_tag" rel="tag" title="Posts tagged with user">user</a> puts in the body field in the <a href="http://www.schuchlenz.com/tag/mail/" class="st_tag internal_tag" rel="tag" title="Posts tagged with mail">mail</a> sending form. Here is the code you have to put in the <a href="http://www.schuchlenz.com/tag/controller/" class="st_tag internal_tag" rel="tag" title="Posts tagged with controller">controller</a> which is supposed to <a href="http://www.schuchlenz.com/tag/send/" class="st_tag internal_tag" rel="tag" title="Posts tagged with send">send</a> the mails (I used admin):</p>
<p><code>def sendEmail<br />&nbsp; params[:recipients].each do |r|<br />&nbsp; MyMailer::deliver_mail(r, params[:subject], params[:body])<br />end</code></p>
<p>The each-loop allows for stuffing multiple recipients into our <a href="http://www.schuchlenz.com/tag/mail/" class="st_tag internal_tag" rel="tag" title="Posts tagged with mail">mail</a> sending function. But we need a form to select these users and provide a subject and body field. So you have to create a view (e.g. admin/sendMyMail.html.erb) and put in something like that:</p>
<p><code>&lt;% form_tag '/admin/sendEmail' do %&gt;<br />&lt;label&gt;Subject:&lt;/label&gt;&lt;br /&gt;<br />&lt;input type="text" name="subject" /&gt;&lt;br /&gt;&lt;br /&gt;<br />&lt;label&gt;Recipients:&lt;/label&gt;&lt;br /&gt;<br />&lt;select name="recipients[]" multiple&gt;<br />&lt;% Recipient.find(:all).each do |r| %&gt;<br />&lt;option value="&lt;%= r.<a href="http://www.schuchlenz.com/tag/mail/" class="st_tag internal_tag" rel="tag" title="Posts tagged with mail">mail</a> %&gt;"&gt;&lt;%= r.firstname + ' ' + r.lastname %&gt;&lt;/option&gt;<br />&lt;% end %&gt;<br />&lt;/select&gt;<br />&lt;br /&gt;&lt;br /&gt;<br />&lt;label&gt;Message:&lt;/label&gt;&lt;br /&gt;<br />&lt;textarea name="body"&gt;&lt;/textarea&gt;<br />&lt;br /&gt;&lt;br /&gt;<br />&lt;input type="submit" value="<a href="http://www.schuchlenz.com/tag/send/" class="st_tag internal_tag" rel="tag" title="Posts tagged with send">send</a> 'em" /&gt;<br />&lt;% end %&gt;</code></p>
<p>I used a model Recipient here, you can of course use any model you want, extract the (rather ugly) database querying and put it in a helper etc.</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share this on:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.schuchlenz.com%2Fmailer-howto-for-rails%2F&amp;partner=sociable" title="Print"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.schuchlenz.com%2Fmailer-howto-for-rails%2F&amp;title=Mailer%20HOWTO%20for%20Rails&amp;bodytext=Since%20sending%20mails%20via%20Rails%20is%20-%20at%20first%20sight%20-%20a%20bit%20tricky%2C%20I%20want%20to%20provide%20you%20with%20a%20quick%20heads%20up%20on%20how%20to%20do%20that.%20Fortunately%20Rails%20provides%20us%20with%20a%20mailer%20generator%20to%20set%20up%20the%20basics%3Aruby%20script%2Fgenerate%20mailer%20MyMailerYou%20can%20of" title="Digg"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.schuchlenz.com%2Fmailer-howto-for-rails%2F&amp;title=Mailer%20HOWTO%20for%20Rails&amp;notes=Since%20sending%20mails%20via%20Rails%20is%20-%20at%20first%20sight%20-%20a%20bit%20tricky%2C%20I%20want%20to%20provide%20you%20with%20a%20quick%20heads%20up%20on%20how%20to%20do%20that.%20Fortunately%20Rails%20provides%20us%20with%20a%20mailer%20generator%20to%20set%20up%20the%20basics%3Aruby%20script%2Fgenerate%20mailer%20MyMailerYou%20can%20of" title="del.icio.us"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.schuchlenz.com%2Fmailer-howto-for-rails%2F&amp;t=Mailer%20HOWTO%20for%20Rails" title="Facebook"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.schuchlenz.com%2Fmailer-howto-for-rails%2F&amp;title=Mailer%20HOWTO%20for%20Rails&amp;annotation=Since%20sending%20mails%20via%20Rails%20is%20-%20at%20first%20sight%20-%20a%20bit%20tricky%2C%20I%20want%20to%20provide%20you%20with%20a%20quick%20heads%20up%20on%20how%20to%20do%20that.%20Fortunately%20Rails%20provides%20us%20with%20a%20mailer%20generator%20to%20set%20up%20the%20basics%3Aruby%20script%2Fgenerate%20mailer%20MyMailerYou%20can%20of" title="Google Bookmarks"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="javascript:AddToFavorites();" title="Add to favorites"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/addtofavorites.png" title="Add to favorites" alt="Add to favorites" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="mailto:?subject=Mailer%20HOWTO%20for%20Rails&amp;body=http%3A%2F%2Fwww.schuchlenz.com%2Fmailer-howto-for-rails%2F" title="email"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.mister-wong.com/addurl/?bm_url=http%3A%2F%2Fwww.schuchlenz.com%2Fmailer-howto-for-rails%2F&amp;bm_description=Mailer%20HOWTO%20for%20Rails&amp;plugin=soc" title="MisterWong"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong" alt="MisterWong" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.schuchlenz.com%2Fmailer-howto-for-rails%2F&amp;t=Mailer%20HOWTO%20for%20Rails" title="MySpace"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.schuchlenz.com%2Fmailer-howto-for-rails%2F&amp;title=Mailer%20HOWTO%20for%20Rails" title="Reddit"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.schuchlenz.com/feed/" title="RSS"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fwww.schuchlenz.com%2Fmailer-howto-for-rails%2F&amp;t=Mailer%20HOWTO%20for%20Rails&opener=bm&amp;ei=UTF-8&amp;d=Since%20sending%20mails%20via%20Rails%20is%20-%20at%20first%20sight%20-%20a%20bit%20tricky%2C%20I%20want%20to%20provide%20you%20with%20a%20quick%20heads%20up%20on%20how%20to%20do%20that.%20Fortunately%20Rails%20provides%20us%20with%20a%20mailer%20generator%20to%20set%20up%20the%20basics%3Aruby%20script%2Fgenerate%20mailer%20MyMailerYou%20can%20of" title="Yahoo! Bookmarks"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a></li>
</ul>
</div>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.schuchlenz.com/quick-and-dirty-guide-to-your-1st-rails-app-part-1/" title="Quick and Dirty Guide to your 1st Rails app &#8211; Part #1 (03.11.2009)">Quick and Dirty Guide to your 1st Rails app &#8211; Part #1</a> (2)</li>
	<li><a href="http://www.schuchlenz.com/activescaffold-how-to-get-started/" title="ActiveScaffold: How to get started (02.11.2009)">ActiveScaffold: How to get started</a> (2)</li>
	<li><a href="http://www.schuchlenz.com/the-numberhelper-in-rails/" title="The NumberHelper in Rails (30.10.2009)">The NumberHelper in Rails</a> (0)</li>
	<li><a href="http://www.schuchlenz.com/symfony-how-to-get-data-from-session-into-form/" title="Symfony: How to get data from session into form (02.11.2009)">Symfony: How to get data from session into form</a> (1)</li>
	<li><a href="http://www.schuchlenz.com/svn-a-quick-howto/" title="SVN: A quick HOWTO (04.11.2009)">SVN: A quick HOWTO</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.schuchlenz.com/mailer-howto-for-rails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SVN: A quick HOWTO</title>
		<link>http://www.schuchlenz.com/svn-a-quick-howto/</link>
		<comments>http://www.schuchlenz.com/svn-a-quick-howto/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 11:20:45 +0000</pubDate>
		<dc:creator>Stefan Schuchlenz</dc:creator>
				<category><![CDATA[Tech Stuff]]></category>
		<category><![CDATA[branches]]></category>
		<category><![CDATA[checkout]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[tags]]></category>
		<category><![CDATA[trunk]]></category>

		<guid isPermaLink="false">http://www.schuchlenz.com/svn-a-quick-howto/</guid>
		<description><![CDATA[If you do a lot of coding, you will experience the need for versioning your code. I have used CVS before switching to SVN and I can only recommend SVN to you &#8211; once you get the hang of it, you will love it. I even use SVN for keeping track of complex HTML templates.
When [...]]]></description>
			<content:encoded><![CDATA[<p>If you do a lot of coding, you will experience the need for versioning your code. I have used CVS before switching to SVN and I can only recommend SVN to you &#8211; once you get the hang of it, you will love it. I even use SVN for keeping track of complex HTML templates.</p>
<p>When using SVN for the first time, I followed a tutorial on the net but it was quite misleading and thus I had quite some trouble with checking in and out.</p>
<p>Let&#8217;s say we have an <a href="http://www.schuchlenz.com/tag/application/" class="st_tag internal_tag" rel="tag" title="Posts tagged with application">application</a> that resides under /var/www/myApp/ and we have a SVN repository over at <code>www.mydomain.com/svn/myAPP</code> (you can create that via <code>svnadmin create myAPP</code> in the <code>svn/</code> directory).</p>
<p>OK, at first, we have to check out the empty repo to a directory (I use /home/joe/myAPP here):</p>
<p><code>svn co http://www.mydomain.com/svn/myAPP /home/joe/myAPP</code></p>
<p>Then, we jump into our temporary repo and create the necessary directories:</p>
<p><code>cd /home/joe/myAPP<br />
mkdir tags branches</code></p>
<p>Done? Good. Let&#8217;s copy our <a href="http://www.schuchlenz.com/tag/application/" class="st_tag internal_tag" rel="tag" title="Posts tagged with application">application</a> to the <a href="http://www.schuchlenz.com/tag/trunk/" class="st_tag internal_tag" rel="tag" title="Posts tagged with trunk">trunk</a>/ directory:</p>
<p><code>cp /var/www/myAPP <a href="http://www.schuchlenz.com/tag/trunk/" class="st_tag internal_tag" rel="tag" title="Posts tagged with trunk">trunk</a> -a</code></p>
<p>Now we can add our 3 folders to the SVN repository (in fact, we only mark them for addition, they are added once we commit our changes by checking in):</p>
<p><code>svn add <a href="http://www.schuchlenz.com/tag/trunk/" class="st_tag internal_tag" rel="tag" title="Posts tagged with trunk">trunk</a> branches tags</code></p>
<p><a href="http://www.schuchlenz.com/tag/trunk/" class="st_tag internal_tag" rel="tag" title="Posts tagged with trunk">trunk</a>, branches and tags directories are now registered as part of our SVN repo. But hey! Let&#8217;s assume we have two folders (private and logs) which we don&#8217;t want to be updated when checking in changes to our repository. We can now set ignore rules to avoid them being checked in:</p>
<p><code>svn propedit svn:ignore .</code></p>
<p>An editor will open &#8211; this can be VIM, nano or whatever you have set as your shells default editor. Enter the following lines and save+close:</p>
<p><code><a href="http://www.schuchlenz.com/tag/trunk/" class="st_tag internal_tag" rel="tag" title="Posts tagged with trunk">trunk</a>/private<br />
<a href="http://www.schuchlenz.com/tag/trunk/" class="st_tag internal_tag" rel="tag" title="Posts tagged with trunk">trunk</a>/logs</code></p>
<p>You can also set single files or wildcard specs to be ignored:</p>
<p><code><a href="http://www.schuchlenz.com/tag/trunk/" class="st_tag internal_tag" rel="tag" title="Posts tagged with trunk">trunk</a>/log/*.log<br />
<a href="http://www.schuchlenz.com/tag/trunk/" class="st_tag internal_tag" rel="tag" title="Posts tagged with trunk">trunk</a>/private/*<br />
<a href="http://www.schuchlenz.com/tag/trunk/" class="st_tag internal_tag" rel="tag" title="Posts tagged with trunk">trunk</a>/private/myDocument.txt</code></p>
<p>Once you&#8217;re done, let&#8217;s check in our changes to the repo:</p>
<p><code>svn ci</code></p>
<p>Now you can enter a message (for the first time I use &#8220;initial commit&#8221;), save+close and you will notice that SVN works on your changes and gives back a revision number. This is your current version.</p>
<p>Once you&#8217;re done, I&#8217;d suggest making an update, removing our repo <a href="http://www.schuchlenz.com/tag/checkout/" class="st_tag internal_tag" rel="tag" title="Posts tagged with checkout">checkout</a> and checking out only <code><a href="http://www.schuchlenz.com/tag/trunk/" class="st_tag internal_tag" rel="tag" title="Posts tagged with trunk">trunk</a>/</code> since you won&#8217;t need tags and branches when working locally:</p>
<p><code>svn up<br />
cd ..<br />
rm -rf myAPP<br />
svn co http://www.mydomain.com/svn/myAPP/<a href="http://www.schuchlenz.com/tag/trunk/" class="st_tag internal_tag" rel="tag" title="Posts tagged with trunk">trunk</a> myAPP</code></p>
<p>Now you&#8217;re set!</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share this on:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.schuchlenz.com%2Fsvn-a-quick-howto%2F&amp;partner=sociable" title="Print"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.schuchlenz.com%2Fsvn-a-quick-howto%2F&amp;title=SVN%3A%20A%20quick%20HOWTO&amp;bodytext=If%20you%20do%20a%20lot%20of%20coding%2C%20you%20will%20experience%20the%20need%20for%20versioning%20your%20code.%20I%20have%20used%20CVS%20before%20switching%20to%20SVN%20and%20I%20can%20only%20recommend%20SVN%20to%20you%20-%20once%20you%20get%20the%20hang%20of%20it%2C%20you%20will%20love%20it.%20I%20even%20use%20SVN%20for%20keeping%20track%20of%20complex" title="Digg"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.schuchlenz.com%2Fsvn-a-quick-howto%2F&amp;title=SVN%3A%20A%20quick%20HOWTO&amp;notes=If%20you%20do%20a%20lot%20of%20coding%2C%20you%20will%20experience%20the%20need%20for%20versioning%20your%20code.%20I%20have%20used%20CVS%20before%20switching%20to%20SVN%20and%20I%20can%20only%20recommend%20SVN%20to%20you%20-%20once%20you%20get%20the%20hang%20of%20it%2C%20you%20will%20love%20it.%20I%20even%20use%20SVN%20for%20keeping%20track%20of%20complex" title="del.icio.us"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.schuchlenz.com%2Fsvn-a-quick-howto%2F&amp;t=SVN%3A%20A%20quick%20HOWTO" title="Facebook"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.schuchlenz.com%2Fsvn-a-quick-howto%2F&amp;title=SVN%3A%20A%20quick%20HOWTO&amp;annotation=If%20you%20do%20a%20lot%20of%20coding%2C%20you%20will%20experience%20the%20need%20for%20versioning%20your%20code.%20I%20have%20used%20CVS%20before%20switching%20to%20SVN%20and%20I%20can%20only%20recommend%20SVN%20to%20you%20-%20once%20you%20get%20the%20hang%20of%20it%2C%20you%20will%20love%20it.%20I%20even%20use%20SVN%20for%20keeping%20track%20of%20complex" title="Google Bookmarks"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="javascript:AddToFavorites();" title="Add to favorites"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/addtofavorites.png" title="Add to favorites" alt="Add to favorites" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="mailto:?subject=SVN%3A%20A%20quick%20HOWTO&amp;body=http%3A%2F%2Fwww.schuchlenz.com%2Fsvn-a-quick-howto%2F" title="email"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.mister-wong.com/addurl/?bm_url=http%3A%2F%2Fwww.schuchlenz.com%2Fsvn-a-quick-howto%2F&amp;bm_description=SVN%3A%20A%20quick%20HOWTO&amp;plugin=soc" title="MisterWong"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong" alt="MisterWong" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.schuchlenz.com%2Fsvn-a-quick-howto%2F&amp;t=SVN%3A%20A%20quick%20HOWTO" title="MySpace"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.schuchlenz.com%2Fsvn-a-quick-howto%2F&amp;title=SVN%3A%20A%20quick%20HOWTO" title="Reddit"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.schuchlenz.com/feed/" title="RSS"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fwww.schuchlenz.com%2Fsvn-a-quick-howto%2F&amp;t=SVN%3A%20A%20quick%20HOWTO&opener=bm&amp;ei=UTF-8&amp;d=If%20you%20do%20a%20lot%20of%20coding%2C%20you%20will%20experience%20the%20need%20for%20versioning%20your%20code.%20I%20have%20used%20CVS%20before%20switching%20to%20SVN%20and%20I%20can%20only%20recommend%20SVN%20to%20you%20-%20once%20you%20get%20the%20hang%20of%20it%2C%20you%20will%20love%20it.%20I%20even%20use%20SVN%20for%20keeping%20track%20of%20complex" title="Yahoo! Bookmarks"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a></li>
</ul>
</div>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.schuchlenz.com/symfony-how-to-get-data-from-session-into-form/" title="Symfony: How to get data from session into form (02.11.2009)">Symfony: How to get data from session into form</a> (1)</li>
	<li><a href="http://www.schuchlenz.com/quick-and-dirty-guide-to-your-1st-rails-app-part-1/" title="Quick and Dirty Guide to your 1st Rails app &#8211; Part #1 (03.11.2009)">Quick and Dirty Guide to your 1st Rails app &#8211; Part #1</a> (2)</li>
	<li><a href="http://www.schuchlenz.com/mailer-howto-for-rails/" title="Mailer HOWTO for Rails (05.11.2009)">Mailer HOWTO for Rails</a> (2)</li>
	<li><a href="http://www.schuchlenz.com/activescaffold-how-to-get-started/" title="ActiveScaffold: How to get started (02.11.2009)">ActiveScaffold: How to get started</a> (2)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.schuchlenz.com/svn-a-quick-howto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick and Dirty Guide to your 1st Rails app &#8211; Part #1</title>
		<link>http://www.schuchlenz.com/quick-and-dirty-guide-to-your-1st-rails-app-part-1/</link>
		<comments>http://www.schuchlenz.com/quick-and-dirty-guide-to-your-1st-rails-app-part-1/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 10:20:42 +0000</pubDate>
		<dc:creator>Stefan Schuchlenz</dc:creator>
				<category><![CDATA[Tech Stuff]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rake]]></category>
		<category><![CDATA[rubygem]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.schuchlenz.com/quick-and-dirty-guide-to-your-1st-rails-app-part-1/</guid>
		<description><![CDATA[For all of you who want to take a peek at creating a Ruby on Rails application and need a quick start, this post is designed to aid you in getting to know RoR. I will post follow-ups to this to make this first application better and better and to incorporate more complex functionality in [...]]]></description>
			<content:encoded><![CDATA[<p>For all of you who want to take a peek at creating a Ruby on <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">Rails</a> <a href="http://www.schuchlenz.com/tag/application/" class="st_tag internal_tag" rel="tag" title="Posts tagged with application">application</a> and need a quick start, this post is designed to aid you in getting to know RoR. I will post follow-ups to this to make this first <a href="http://www.schuchlenz.com/tag/application/" class="st_tag internal_tag" rel="tag" title="Posts tagged with application">application</a> better and better and to incorporate more complex functionality in a step-by-step manner.<br />
<span id="more-81"></span>Ok, so you want to quickly get started with your first <a href="http://www.schuchlenz.com/tag/application/" class="st_tag internal_tag" rel="tag" title="Posts tagged with application">application</a> in Ruby on <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">Rails</a>? Here we go&#8230;</p>
<p>First, <a href="http://www.schuchlenz.com/tag/install/" class="st_tag internal_tag" rel="tag" title="Posts tagged with install">install</a> <code>rubygems</code> via your favourite package manager or head over to <a href="http://www.rubyonrails.org" target="_blank">www.rubyonrails.org</a>, grab the package and follow the instructions. Then <a href="http://www.schuchlenz.com/tag/install/" class="st_tag internal_tag" rel="tag" title="Posts tagged with install">install</a> some gems you need (I assume you like mySQL so I <a href="http://www.schuchlenz.com/tag/install/" class="st_tag internal_tag" rel="tag" title="Posts tagged with install">install</a> the mysql gem for DB connection but you can of course also go with postgreSQL or sqlite).</p>
<p><strong><em>Notice: this guide is written for Linux!</em></strong></p>
<p>Make sure you have the development libs of your favourite database (mySQL, &#8230;) installed or else you will run into trouble when installing the gems.</p>
<p><code>sudo gem <a href="http://www.schuchlenz.com/tag/install/" class="st_tag internal_tag" rel="tag" title="Posts tagged with install">install</a> <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">rails</a> mysql <a href="http://www.schuchlenz.com/tag/rake/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rake">rake</a> railroad</code></p>
<p>This will <a href="http://www.schuchlenz.com/tag/install/" class="st_tag internal_tag" rel="tag" title="Posts tagged with install">install</a> <code><a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">rails</a></code>, the mysql connector, the <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">rails</a> make tool <code><a href="http://www.schuchlenz.com/tag/rake/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rake">rake</a></code> (which is needed for several tasks from migrating to stuff to your database, inserting prepared <a href="http://www.schuchlenz.com/tag/data/" class="st_tag internal_tag" rel="tag" title="Posts tagged with data">data</a> into it or updating your javascripts and much more).</p>
<p>Now you&#8217;re set to pick a folder (I tend to make a <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">rails</a>/ folder in my home dir) for your <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">rails</a> apps:</p>
<p><code>mkdir /home/&lt;myusername&gt;/<a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">rails</a></code></p>
<p>and create your first <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">rails</a> app:</p>
<p><code>cd /home/&lt;myusername&gt;/<a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">rails</a>/<br />
<a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">rails</a> -d mysql myFirstApp<br />
cd myFirstApp</code></p>
<p>You will notice that <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">rails</a> has created some folder for you. The ones that concern us at the moment are:</p>
<p><code>app/<br />
config/<br />
db/<br />
public/<br />
script/<br />
vendor/</code></p>
<p>In <code>app/</code> all the necessary controllers, models and views as well as partials live (we&#8217;ll get to that later), <code>config/</code> contains configuration files and environment-specific extra configuration as well as the database schema file, <code>db/</code> contains the database migrations we need to spice up our database, <code>public/</code> contains stuff like javascripts, images, stylesheets etc. and <code>vendor/</code> is the place where we can put our gems and plugins.</p>
<p>An especially important directory is <code>script/ </code>which contains our generators (which provide us with means of creating functionality, models etc.) and the launcher for <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">Rails</a>&#8217; built-in webserver.</p>
<p><strong><em>Important hint: DO NOT delete these folders unless you know what you are doing &#8211; it WILL break your app!</em></strong></p>
<p>I know this is a bit hefty at the moment, but trust me &#8211; it will become clear once we work with the files and folders (I will introduce some of the concepts of Model-View-<a href="http://www.schuchlenz.com/tag/controller/" class="st_tag internal_tag" rel="tag" title="Posts tagged with controller">Controller</a> (MVC), the <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">Rails</a> concepts and basic ideas and so on throughout this <a href="http://www.schuchlenz.com/tag/tutorial/" class="st_tag internal_tag" rel="tag" title="Posts tagged with tutorial">tutorial</a>).</p>
<p>Let&#8217;s jump right into the action and take a look at our database config. Start by editing <code>config/database.yml</code> :</p>
<p>After a clean <a href="http://www.schuchlenz.com/tag/install/" class="st_tag internal_tag" rel="tag" title="Posts tagged with install">install</a>, it will look like this:</p>
<p><code><br />
development:<br />
adapter: mysql<br />
encoding: utf8<br />
reconnect: false<br />
database: myFirstApp_development<br />
pool: 5<br />
username: root<br />
password:<br />
socket: /var/run/mysqld/mysqld.sock<br />
</code><br />
<code><br />
# Warning: The database defined as "test" will be erased and<br />
# re-generated from your development database when you run "<a href="http://www.schuchlenz.com/tag/rake/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rake">rake</a>".<br />
# Do not set this db to the same as development or production.<br />
test:<br />
adapter: mysql<br />
encoding: utf8<br />
reconnect: false<br />
database: myFirstApp_test<br />
pool: 5<br />
username: root<br />
password:<br />
socket: /var/run/mysqld/mysqld.sock<br />
</code><br />
<code><br />
production:<br />
adapter: mysql<br />
encoding: utf8<br />
reconnect: false<br />
database: myFirstApp_production<br />
pool: 5<br />
username: root<br />
password:<br />
socket: /var/run/mysqld/mysqld.sock<br />
</code><br />
Since I take it you know how to create a database and how mySQL works &#8211; just fill in the appropriate <a href="http://www.schuchlenz.com/tag/data/" class="st_tag internal_tag" rel="tag" title="Posts tagged with data">data</a> in the fields and save it. You may change the database names but I strongly recommend you to to keep the syntax of dbname_test, dbname_development and so on.</p>
<p>Done? Great! Now let&#8217;s tell <code><a href="http://www.schuchlenz.com/tag/rake/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rake">rake</a></code> to create our databases:</p>
<p><code><a href="http://www.schuchlenz.com/tag/rake/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rake">rake</a> db:create:all</code></p>
<p>If you take a look at your mySQL server (e.g. via phpMyAdmin) you see that <code><a href="http://www.schuchlenz.com/tag/rake/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rake">rake</a></code> has created the databases for us. You may now fire up the server:</p>
<p><code>ruby script/server</code></p>
<p>and head on to <code>http://localhost:3000</code> to see a RoR placeholder there. So far so good. Now remove the index.html page from <code>public/</code> since it is just the placeholder page and reload your browser window &#8211; ooops! An error has occured. Get used to these nifty error messages from RoR &#8211; you will see many of them, trust me <img src='http://www.schuchlenz.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>But no hassle &#8211; we will fix this immediately. The cause of this error is that we have killed the placeholder but our <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">Rails</a> app doesn&#8217;t know where to go now. So we have to tell it the right way to a <a href="http://www.schuchlenz.com/tag/controller/" class="st_tag internal_tag" rel="tag" title="Posts tagged with controller">controller</a> (which we don&#8217;t have yet) so myFirstApp can display something. For this, we have to create a <a href="http://www.schuchlenz.com/tag/controller/" class="st_tag internal_tag" rel="tag" title="Posts tagged with controller">controller</a>:</p>
<p>ruby script/generate <a href="http://www.schuchlenz.com/tag/controller/" class="st_tag internal_tag" rel="tag" title="Posts tagged with controller">controller</a> welcome</p>
<p>Now you will see that <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">Rails</a> creates some files:</p>
<p><code>exists  app/controllers/<br />
exists  app/helpers/<br />
create  app/views/welcome<br />
exists  test/functional/<br />
create  test/unit/helpers/<br />
create  app/controllers/welcome_controller.rb<br />
create  test/functional/welcome_controller_test.rb<br />
create  app/helpers/welcome_helper.rb<br />
create  test/unit/helpers/welcome_helper_test.rb</code></p>
<p>exists means that <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">Rails</a> has found out that the directory already exists so it won&#8217;t be created, created means that <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">Rails</a> has created a file or folder.</p>
<p>In app/, <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">Rails</a> has created a <a href="http://www.schuchlenz.com/tag/controller/" class="st_tag internal_tag" rel="tag" title="Posts tagged with controller">controller</a> (where our programming goes), a model (which basically is our database table), a view folder (where we can put HTML files to display what the <a href="http://www.schuchlenz.com/tag/controller/" class="st_tag internal_tag" rel="tag" title="Posts tagged with controller">controller</a> pulls from the model) and a helpers folder. We will discuss these later, just let&#8217;s stay straight and take a look at our <a href="http://www.schuchlenz.com/tag/controller/" class="st_tag internal_tag" rel="tag" title="Posts tagged with controller">controller</a>:</p>
<p><code>class WelcomeController &lt; ApplicationController<br />
end<br />
</code><br />
Not much here, eh? So let&#8217;s put an index action there which controls what is displayed when one calls <code>http://localhost:3000/welcome/</code> in the browser:</p>
<p><code>def index<br />
@<a href="http://www.schuchlenz.com/tag/data/" class="st_tag internal_tag" rel="tag" title="Posts tagged with data">data</a> = "Hello World..."<br />
end</code></p>
<p><em><strong>Notice: If you have not taken a look at Ruby and its reference &#8211; this will definitely a good time to do so or else you won&#8217;t be capable to code stuff for your <a href="http://www.schuchlenz.com/tag/application/" class="st_tag internal_tag" rel="tag" title="Posts tagged with application">application</a>!</strong></em></p>
<p>Ok, what is this? @<a href="http://www.schuchlenz.com/tag/data/" class="st_tag internal_tag" rel="tag" title="Posts tagged with data">data</a> is a variable which contains the string &#8220;Hello World&#8230;&#8221;. This variable has been defined inside the index function of our <a href="http://www.schuchlenz.com/tag/controller/" class="st_tag internal_tag" rel="tag" title="Posts tagged with controller">controller</a> which means that in our index view, we can use it. But &#8211; guess what? Right, we have no index view yet. So let&#8217;s create it. That&#8217;s simple: just put a file named <code>view.html.erb</code> in our app/views/welcome/ folder. There, just put one line:</p>
<p><code>&lt;%= @<a href="http://www.schuchlenz.com/tag/data/" class="st_tag internal_tag" rel="tag" title="Posts tagged with data">data</a> %&gt;</code></p>
<p>What the heck is this? Tataa&#8230; it&#8217;s ruby code! <code>&lt;%=</code> basically is the same as <code>&lt;?php echo</code> or <code>&lt;?php print </code>- it puts out the <a href="http://www.schuchlenz.com/tag/data/" class="st_tag internal_tag" rel="tag" title="Posts tagged with data">data</a> our variable is holding to the browser. So when you call our brand new index view via</p>
<p><code>http://localhost:3000/welcome/</code></p>
<p>you will see that &#8220;Hello World&#8230;&#8221; is displayed. For now, we want that our welcome <a href="http://www.schuchlenz.com/tag/controller/" class="st_tag internal_tag" rel="tag" title="Posts tagged with controller">controller</a> view is called whenever someone navigates to the root of our <a href="http://www.schuchlenz.com/tag/application/" class="st_tag internal_tag" rel="tag" title="Posts tagged with application">application</a> by entering <code>http://localhost:3000</code> &#8211; we can achieve this via <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">Rails</a>&#8217; routing configuration in <code>config/routes.rb</code>:</p>
<p>When you open this file in your editor, you notice a lot of stuff that&#8217;s already there. At the moment, only the line</p>
<p><code># map.root :<a href="http://www.schuchlenz.com/tag/controller/" class="st_tag internal_tag" rel="tag" title="Posts tagged with controller">controller</a> =&gt; "welcome"</code></p>
<p>is interesting. Simply remove the # to uncomment it, save the file and restart the server (CTRL+C in the shell and then start it up again). That&#8217;s it &#8211; welcome is now our main <a href="http://www.schuchlenz.com/tag/controller/" class="st_tag internal_tag" rel="tag" title="Posts tagged with controller">controller</a>! And that&#8217;s it for our first lesson &#8211; you have created your first <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">Rails</a> <a href="http://www.schuchlenz.com/tag/application/" class="st_tag internal_tag" rel="tag" title="Posts tagged with application">application</a>!</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share this on:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.schuchlenz.com%2Fquick-and-dirty-guide-to-your-1st-rails-app-part-1%2F&amp;partner=sociable" title="Print"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.schuchlenz.com%2Fquick-and-dirty-guide-to-your-1st-rails-app-part-1%2F&amp;title=Quick%20and%20Dirty%20Guide%20to%20your%201st%20Rails%20app%20-%20Part%20%231&amp;bodytext=For%20all%20of%20you%20who%20want%20to%20take%20a%20peek%20at%20creating%20a%20Ruby%20on%20Rails%20application%20and%20need%20a%20quick%20start%2C%20this%20post%20is%20designed%20to%20aid%20you%20in%20getting%20to%20know%20RoR.%20I%20will%20post%20follow-ups%20to%20this%20to%20make%20this%20first%20application%20better%20and%20better%20and%20to%20inc" title="Digg"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.schuchlenz.com%2Fquick-and-dirty-guide-to-your-1st-rails-app-part-1%2F&amp;title=Quick%20and%20Dirty%20Guide%20to%20your%201st%20Rails%20app%20-%20Part%20%231&amp;notes=For%20all%20of%20you%20who%20want%20to%20take%20a%20peek%20at%20creating%20a%20Ruby%20on%20Rails%20application%20and%20need%20a%20quick%20start%2C%20this%20post%20is%20designed%20to%20aid%20you%20in%20getting%20to%20know%20RoR.%20I%20will%20post%20follow-ups%20to%20this%20to%20make%20this%20first%20application%20better%20and%20better%20and%20to%20inc" title="del.icio.us"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.schuchlenz.com%2Fquick-and-dirty-guide-to-your-1st-rails-app-part-1%2F&amp;t=Quick%20and%20Dirty%20Guide%20to%20your%201st%20Rails%20app%20-%20Part%20%231" title="Facebook"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.schuchlenz.com%2Fquick-and-dirty-guide-to-your-1st-rails-app-part-1%2F&amp;title=Quick%20and%20Dirty%20Guide%20to%20your%201st%20Rails%20app%20-%20Part%20%231&amp;annotation=For%20all%20of%20you%20who%20want%20to%20take%20a%20peek%20at%20creating%20a%20Ruby%20on%20Rails%20application%20and%20need%20a%20quick%20start%2C%20this%20post%20is%20designed%20to%20aid%20you%20in%20getting%20to%20know%20RoR.%20I%20will%20post%20follow-ups%20to%20this%20to%20make%20this%20first%20application%20better%20and%20better%20and%20to%20inc" title="Google Bookmarks"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="javascript:AddToFavorites();" title="Add to favorites"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/addtofavorites.png" title="Add to favorites" alt="Add to favorites" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="mailto:?subject=Quick%20and%20Dirty%20Guide%20to%20your%201st%20Rails%20app%20-%20Part%20%231&amp;body=http%3A%2F%2Fwww.schuchlenz.com%2Fquick-and-dirty-guide-to-your-1st-rails-app-part-1%2F" title="email"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.mister-wong.com/addurl/?bm_url=http%3A%2F%2Fwww.schuchlenz.com%2Fquick-and-dirty-guide-to-your-1st-rails-app-part-1%2F&amp;bm_description=Quick%20and%20Dirty%20Guide%20to%20your%201st%20Rails%20app%20-%20Part%20%231&amp;plugin=soc" title="MisterWong"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong" alt="MisterWong" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.schuchlenz.com%2Fquick-and-dirty-guide-to-your-1st-rails-app-part-1%2F&amp;t=Quick%20and%20Dirty%20Guide%20to%20your%201st%20Rails%20app%20-%20Part%20%231" title="MySpace"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.schuchlenz.com%2Fquick-and-dirty-guide-to-your-1st-rails-app-part-1%2F&amp;title=Quick%20and%20Dirty%20Guide%20to%20your%201st%20Rails%20app%20-%20Part%20%231" title="Reddit"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.schuchlenz.com/feed/" title="RSS"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fwww.schuchlenz.com%2Fquick-and-dirty-guide-to-your-1st-rails-app-part-1%2F&amp;t=Quick%20and%20Dirty%20Guide%20to%20your%201st%20Rails%20app%20-%20Part%20%231&opener=bm&amp;ei=UTF-8&amp;d=For%20all%20of%20you%20who%20want%20to%20take%20a%20peek%20at%20creating%20a%20Ruby%20on%20Rails%20application%20and%20need%20a%20quick%20start%2C%20this%20post%20is%20designed%20to%20aid%20you%20in%20getting%20to%20know%20RoR.%20I%20will%20post%20follow-ups%20to%20this%20to%20make%20this%20first%20application%20better%20and%20better%20and%20to%20inc" title="Yahoo! Bookmarks"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a></li>
</ul>
</div>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.schuchlenz.com/rails-extracting-fixtures-from-databases/" title="Rails: Extracting fixtures from databases (30.10.2009)">Rails: Extracting fixtures from databases</a> (0)</li>
	<li><a href="http://www.schuchlenz.com/mailer-howto-for-rails/" title="Mailer HOWTO for Rails (05.11.2009)">Mailer HOWTO for Rails</a> (2)</li>
	<li><a href="http://www.schuchlenz.com/activescaffold-how-to-get-started/" title="ActiveScaffold: How to get started (02.11.2009)">ActiveScaffold: How to get started</a> (2)</li>
	<li><a href="http://www.schuchlenz.com/the-numberhelper-in-rails/" title="The NumberHelper in Rails (30.10.2009)">The NumberHelper in Rails</a> (0)</li>
	<li><a href="http://www.schuchlenz.com/symfony-how-to-get-data-from-session-into-form/" title="Symfony: How to get data from session into form (02.11.2009)">Symfony: How to get data from session into form</a> (1)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.schuchlenz.com/quick-and-dirty-guide-to-your-1st-rails-app-part-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ActiveScaffold: How to get started</title>
		<link>http://www.schuchlenz.com/activescaffold-how-to-get-started/</link>
		<comments>http://www.schuchlenz.com/activescaffold-how-to-get-started/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 10:27:18 +0000</pubDate>
		<dc:creator>Stefan Schuchlenz</dc:creator>
				<category><![CDATA[Tech Stuff]]></category>
		<category><![CDATA[activescaffold]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[resource]]></category>
		<category><![CDATA[route]]></category>
		<category><![CDATA[setup]]></category>

		<guid isPermaLink="false">http://www.schuchlenz.com/activescaffold-how-to-get-started/</guid>
		<description><![CDATA[When I took a first peek at ActiveScaffold, I had no idea into how much trouble I&#8217;d run before creating beautiful AND working backends for my applications. I had LOTS of research to do to get around some rather nasty issues and I want to provide you with some info on how to get stuff [...]]]></description>
			<content:encoded><![CDATA[<p>When I took a first peek at <a href="http://www.schuchlenz.com/tag/activescaffold/" class="st_tag internal_tag" rel="tag" title="Posts tagged with activescaffold">ActiveScaffold</a>, I had no idea into how much trouble I&#8217;d run before creating beautiful AND working backends for my applications. I had LOTS of research to do to get around some rather nasty issues and I want to provide you with some info on how to get stuff done.</p>
<p><b>Some prerequisites:</b><br />
I use <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">Rails</a> 2.3.4 at the time this is posted and my gem list shows:</p>
<p>actionmailer (2.3.4)<br />
actionpack (2.3.4)<br />
activerecord (2.3.4)<br />
activeresource (2.3.4)<br />
activesupport (2.3.4)<br />
flickraw (0.7.1)<br />
json (1.1.9)<br />
locale (2.0.4)<br />
locale_rails (2.0.4)<br />
mime-types (1.16)<br />
mysql (2.8.1)<br />
rack (1.0.0)<br />
railroad (0.5.0)<br />
<a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">rails</a> (2.3.4)<br />
<a href="http://www.schuchlenz.com/tag/rake/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rake">rake</a> (0.8.7)<br />
thoughtbot-paperclip (2.3.1)</p>
<p><b>Installation:</b><br />
To <a href="http://www.schuchlenz.com/tag/install/" class="st_tag internal_tag" rel="tag" title="Posts tagged with install">install</a> AS, open a shell and type:<br />
<code>ruby script/plugin <a href="http://www.schuchlenz.com/tag/install/" class="st_tag internal_tag" rel="tag" title="Posts tagged with install">install</a> git://github.com/<a href="http://www.schuchlenz.com/tag/activescaffold/" class="st_tag internal_tag" rel="tag" title="Posts tagged with activescaffold">activescaffold</a>/active_scaffold.git</code><br />
Installs AS and all the necessary stuff<br />
<code>ruby script/plugin <a href="http://www.schuchlenz.com/tag/install/" class="st_tag internal_tag" rel="tag" title="Posts tagged with install">install</a> git://github.com/<a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">rails</a>/in_place_editing.git</code><br />
Ooops, in place editing was missing &#8211; so let&#8217;s <a href="http://www.schuchlenz.com/tag/install/" class="st_tag internal_tag" rel="tag" title="Posts tagged with install">install</a> it.<br />
<code>ruby script/plugin <a href="http://www.schuchlenz.com/tag/install/" class="st_tag internal_tag" rel="tag" title="Posts tagged with install">install</a> --force git://github.com/lackac/render_component.git -r <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">rails</a>-edge'</code><br />
Ooops again, render_component was taken out of <a href="http://www.schuchlenz.com/tag/rails/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rails">Rails</a> so subforms wouldn&#8217;t work &#8211; let&#8217;s get around this by installing lackac&#8217;s plugin (thanks!)</p>
<p><b>OK, basically, you are set. What now?</b><br />
The <a href="http://www.schuchlenz.com/tag/activescaffold/" class="st_tag internal_tag" rel="tag" title="Posts tagged with activescaffold">ActiveScaffold</a> website (www.<a href="http://www.schuchlenz.com/tag/activescaffold/" class="st_tag internal_tag" rel="tag" title="Posts tagged with activescaffold">activescaffold</a>.com) and especially their API docs are your bible. So read them, re-read them and re-re-read them while building stuff with AS &#8211; you will need the (rudimentary) tipps included there.<br />
Ok, now let&#8217;s start with integrating AS into our app. Let&#8217;s say you have a basic <a href="http://www.schuchlenz.com/tag/application/" class="st_tag internal_tag" rel="tag" title="Posts tagged with application">application</a> which already has a master layout. Put this tag into the <HEAD> of your layout:</p>
<p><code><%= active_scaffold_includes %></code></p>
<p>It includes all the magic needed for AS. To continue, you should have a resource we can work on, in this case I created a resource named &#8220;customer&#8221; to store some customer info in it and work on it with AS:</p>
<p><code>ruby script/generate resource customer name:string phone:string email:string description:string is_active:boolean</code></p>
<p>Migrate the <a href="http://www.schuchlenz.com/tag/data/" class="st_tag internal_tag" rel="tag" title="Posts tagged with data">data</a> now:</p>
<p><code><a href="http://www.schuchlenz.com/tag/rake/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rake">rake</a> db:migrate</code></p>
<p>Edit your customers_controller.rb in app/controllers and put</p>
<p><code>active_scaffold :customer do |config|<br />
end</code></p>
<p>right after</p>
<p><code>class CustomerController < ApplicationController</code></p>
<p>to make AS aware that it should take care of our customers. Now open config/routes.rb and add :active_scaffold => true right after the customer resource. When you start your server and call /customers, you now should see AS in action. Congratulations, this was the first part <img src='http://www.schuchlenz.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share this on:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.schuchlenz.com%2Factivescaffold-how-to-get-started%2F&amp;partner=sociable" title="Print"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.schuchlenz.com%2Factivescaffold-how-to-get-started%2F&amp;title=ActiveScaffold%3A%20How%20to%20get%20started&amp;bodytext=When%20I%20took%20a%20first%20peek%20at%20ActiveScaffold%2C%20I%20had%20no%20idea%20into%20how%20much%20trouble%20I%27d%20run%20before%20creating%20beautiful%20AND%20working%20backends%20for%20my%20applications.%20I%20had%20LOTS%20of%20research%20to%20do%20to%20get%20around%20some%20rather%20nasty%20issues%20and%20I%20want%20to%20provide%20you%20" title="Digg"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.schuchlenz.com%2Factivescaffold-how-to-get-started%2F&amp;title=ActiveScaffold%3A%20How%20to%20get%20started&amp;notes=When%20I%20took%20a%20first%20peek%20at%20ActiveScaffold%2C%20I%20had%20no%20idea%20into%20how%20much%20trouble%20I%27d%20run%20before%20creating%20beautiful%20AND%20working%20backends%20for%20my%20applications.%20I%20had%20LOTS%20of%20research%20to%20do%20to%20get%20around%20some%20rather%20nasty%20issues%20and%20I%20want%20to%20provide%20you%20" title="del.icio.us"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.schuchlenz.com%2Factivescaffold-how-to-get-started%2F&amp;t=ActiveScaffold%3A%20How%20to%20get%20started" title="Facebook"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.schuchlenz.com%2Factivescaffold-how-to-get-started%2F&amp;title=ActiveScaffold%3A%20How%20to%20get%20started&amp;annotation=When%20I%20took%20a%20first%20peek%20at%20ActiveScaffold%2C%20I%20had%20no%20idea%20into%20how%20much%20trouble%20I%27d%20run%20before%20creating%20beautiful%20AND%20working%20backends%20for%20my%20applications.%20I%20had%20LOTS%20of%20research%20to%20do%20to%20get%20around%20some%20rather%20nasty%20issues%20and%20I%20want%20to%20provide%20you%20" title="Google Bookmarks"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="javascript:AddToFavorites();" title="Add to favorites"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/addtofavorites.png" title="Add to favorites" alt="Add to favorites" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="mailto:?subject=ActiveScaffold%3A%20How%20to%20get%20started&amp;body=http%3A%2F%2Fwww.schuchlenz.com%2Factivescaffold-how-to-get-started%2F" title="email"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.mister-wong.com/addurl/?bm_url=http%3A%2F%2Fwww.schuchlenz.com%2Factivescaffold-how-to-get-started%2F&amp;bm_description=ActiveScaffold%3A%20How%20to%20get%20started&amp;plugin=soc" title="MisterWong"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong" alt="MisterWong" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.schuchlenz.com%2Factivescaffold-how-to-get-started%2F&amp;t=ActiveScaffold%3A%20How%20to%20get%20started" title="MySpace"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.schuchlenz.com%2Factivescaffold-how-to-get-started%2F&amp;title=ActiveScaffold%3A%20How%20to%20get%20started" title="Reddit"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.schuchlenz.com/feed/" title="RSS"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fwww.schuchlenz.com%2Factivescaffold-how-to-get-started%2F&amp;t=ActiveScaffold%3A%20How%20to%20get%20started&opener=bm&amp;ei=UTF-8&amp;d=When%20I%20took%20a%20first%20peek%20at%20ActiveScaffold%2C%20I%20had%20no%20idea%20into%20how%20much%20trouble%20I%27d%20run%20before%20creating%20beautiful%20AND%20working%20backends%20for%20my%20applications.%20I%20had%20LOTS%20of%20research%20to%20do%20to%20get%20around%20some%20rather%20nasty%20issues%20and%20I%20want%20to%20provide%20you%20" title="Yahoo! Bookmarks"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a></li>
</ul>
</div>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.schuchlenz.com/rails-integrate-fckeditor-with-activescaffold/" title="Rails: Integrate FCKEditor with ActiveScaffold (30.10.2009)">Rails: Integrate FCKEditor with ActiveScaffold</a> (0)</li>
	<li><a href="http://www.schuchlenz.com/quick-and-dirty-guide-to-your-1st-rails-app-part-1/" title="Quick and Dirty Guide to your 1st Rails app &#8211; Part #1 (03.11.2009)">Quick and Dirty Guide to your 1st Rails app &#8211; Part #1</a> (2)</li>
	<li><a href="http://www.schuchlenz.com/must-have-plugins-for-rails/" title="Must-have plugins for Rails (30.10.2009)">Must-have plugins for Rails</a> (0)</li>
	<li><a href="http://www.schuchlenz.com/mailer-howto-for-rails/" title="Mailer HOWTO for Rails (05.11.2009)">Mailer HOWTO for Rails</a> (2)</li>
	<li><a href="http://www.schuchlenz.com/the-numberhelper-in-rails/" title="The NumberHelper in Rails (30.10.2009)">The NumberHelper in Rails</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.schuchlenz.com/activescaffold-how-to-get-started/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Symfony: How to get data from session into form</title>
		<link>http://www.schuchlenz.com/symfony-how-to-get-data-from-session-into-form/</link>
		<comments>http://www.schuchlenz.com/symfony-how-to-get-data-from-session-into-form/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 08:59:36 +0000</pubDate>
		<dc:creator>Stefan Schuchlenz</dc:creator>
				<category><![CDATA[Tech Stuff]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[partial]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[user]]></category>

		<guid isPermaLink="false">http://www.schuchlenz.com/symfony-how-to-get-data-from-session-into-form/</guid>
		<description><![CDATA[I tried to put the user id from the session into a hidden form field and &#8211; guess what? I tried for friggin&#8217; 30 minutes to figure out how.
In standard PHP, you would have put &#60;?php echo $_SESSION['userId'] ?&#62;  and be set, but in Symfony, you have to put sfContext::getInstance()-&#62;getUser()-&#62;getAttribute('...'); in your action to [...]]]></description>
			<content:encoded><![CDATA[<p>I tried to put the <a href="http://www.schuchlenz.com/tag/user/" class="st_tag internal_tag" rel="tag" title="Posts tagged with user">user</a> id from the <a href="http://www.schuchlenz.com/tag/session/" class="st_tag internal_tag" rel="tag" title="Posts tagged with session">session</a> into a hidden <a href="http://www.schuchlenz.com/tag/form/" class="st_tag internal_tag" rel="tag" title="Posts tagged with form">form</a> field and &#8211; guess what? I tried for friggin&#8217; 30 minutes to figure out how.</p>
<p>In standard PHP, you would have put <code>&lt;?php echo $_SESSION['userId'] ?&gt;</code>  and be set, but in <a href="http://www.schuchlenz.com/tag/symfony/" class="st_tag internal_tag" rel="tag" title="Posts tagged with symfony">Symfony</a>, you have to put <code>sfContext::getInstance()-&gt;getUser()-&gt;getAttribute('...');</code> in your action to get it to work.</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share this on:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.schuchlenz.com%2Fsymfony-how-to-get-data-from-session-into-form%2F&amp;partner=sociable" title="Print"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.schuchlenz.com%2Fsymfony-how-to-get-data-from-session-into-form%2F&amp;title=Symfony%3A%20How%20to%20get%20data%20from%20session%20into%20form&amp;bodytext=I%20tried%20to%20put%20the%20user%20id%20from%20the%20session%20into%20a%20hidden%20form%20field%20and%20-%20guess%20what%3F%20I%20tried%20for%20friggin%27%2030%20minutes%20to%20figure%20out%20how.%0D%0A%0D%0AIn%20standard%20PHP%2C%20you%20would%20have%20put%20%26lt%3B%3Fphp%20echo%20%24_SESSION%5B%27userId%27%5D%20%3F%26gt%3B%20%20and%20be%20set%2C%20but%20in%20Symfony%2C%20you%20" title="Digg"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.schuchlenz.com%2Fsymfony-how-to-get-data-from-session-into-form%2F&amp;title=Symfony%3A%20How%20to%20get%20data%20from%20session%20into%20form&amp;notes=I%20tried%20to%20put%20the%20user%20id%20from%20the%20session%20into%20a%20hidden%20form%20field%20and%20-%20guess%20what%3F%20I%20tried%20for%20friggin%27%2030%20minutes%20to%20figure%20out%20how.%0D%0A%0D%0AIn%20standard%20PHP%2C%20you%20would%20have%20put%20%26lt%3B%3Fphp%20echo%20%24_SESSION%5B%27userId%27%5D%20%3F%26gt%3B%20%20and%20be%20set%2C%20but%20in%20Symfony%2C%20you%20" title="del.icio.us"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.schuchlenz.com%2Fsymfony-how-to-get-data-from-session-into-form%2F&amp;t=Symfony%3A%20How%20to%20get%20data%20from%20session%20into%20form" title="Facebook"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.schuchlenz.com%2Fsymfony-how-to-get-data-from-session-into-form%2F&amp;title=Symfony%3A%20How%20to%20get%20data%20from%20session%20into%20form&amp;annotation=I%20tried%20to%20put%20the%20user%20id%20from%20the%20session%20into%20a%20hidden%20form%20field%20and%20-%20guess%20what%3F%20I%20tried%20for%20friggin%27%2030%20minutes%20to%20figure%20out%20how.%0D%0A%0D%0AIn%20standard%20PHP%2C%20you%20would%20have%20put%20%26lt%3B%3Fphp%20echo%20%24_SESSION%5B%27userId%27%5D%20%3F%26gt%3B%20%20and%20be%20set%2C%20but%20in%20Symfony%2C%20you%20" title="Google Bookmarks"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="javascript:AddToFavorites();" title="Add to favorites"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/addtofavorites.png" title="Add to favorites" alt="Add to favorites" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="mailto:?subject=Symfony%3A%20How%20to%20get%20data%20from%20session%20into%20form&amp;body=http%3A%2F%2Fwww.schuchlenz.com%2Fsymfony-how-to-get-data-from-session-into-form%2F" title="email"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.mister-wong.com/addurl/?bm_url=http%3A%2F%2Fwww.schuchlenz.com%2Fsymfony-how-to-get-data-from-session-into-form%2F&amp;bm_description=Symfony%3A%20How%20to%20get%20data%20from%20session%20into%20form&amp;plugin=soc" title="MisterWong"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/misterwong.png" title="MisterWong" alt="MisterWong" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.schuchlenz.com%2Fsymfony-how-to-get-data-from-session-into-form%2F&amp;t=Symfony%3A%20How%20to%20get%20data%20from%20session%20into%20form" title="MySpace"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.schuchlenz.com%2Fsymfony-how-to-get-data-from-session-into-form%2F&amp;title=Symfony%3A%20How%20to%20get%20data%20from%20session%20into%20form" title="Reddit"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.schuchlenz.com/feed/" title="RSS"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fwww.schuchlenz.com%2Fsymfony-how-to-get-data-from-session-into-form%2F&amp;t=Symfony%3A%20How%20to%20get%20data%20from%20session%20into%20form&opener=bm&amp;ei=UTF-8&amp;d=I%20tried%20to%20put%20the%20user%20id%20from%20the%20session%20into%20a%20hidden%20form%20field%20and%20-%20guess%20what%3F%20I%20tried%20for%20friggin%27%2030%20minutes%20to%20figure%20out%20how.%0D%0A%0D%0AIn%20standard%20PHP%2C%20you%20would%20have%20put%20%26lt%3B%3Fphp%20echo%20%24_SESSION%5B%27userId%27%5D%20%3F%26gt%3B%20%20and%20be%20set%2C%20but%20in%20Symfony%2C%20you%20" title="Yahoo! Bookmarks"><img src="http://www.schuchlenz.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a></li>
</ul>
</div>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.schuchlenz.com/symfony-allowing-extra-field-in-validated-forms/" title="Symfony: Allowing extra field in validated forms (04.11.2009)">Symfony: Allowing extra field in validated forms</a> (0)</li>
	<li><a href="http://www.schuchlenz.com/svn-a-quick-howto/" title="SVN: A quick HOWTO (04.11.2009)">SVN: A quick HOWTO</a> (0)</li>
	<li><a href="http://www.schuchlenz.com/quick-and-dirty-guide-to-your-1st-rails-app-part-1/" title="Quick and Dirty Guide to your 1st Rails app &#8211; Part #1 (03.11.2009)">Quick and Dirty Guide to your 1st Rails app &#8211; Part #1</a> (2)</li>
	<li><a href="http://www.schuchlenz.com/mailer-howto-for-rails/" title="Mailer HOWTO for Rails (05.11.2009)">Mailer HOWTO for Rails</a> (2)</li>
	<li><a href="http://www.schuchlenz.com/activescaffold-how-to-get-started/" title="ActiveScaffold: How to get started (02.11.2009)">ActiveScaffold: How to get started</a> (2)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.schuchlenz.com/symfony-how-to-get-data-from-session-into-form/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
