<?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>Meseret Gebre &#187; Rails</title>
	<atom:link href="http://meseretgebre.com/archives/tag/ror/feed/" rel="self" type="application/rss+xml" />
	<link>http://meseretgebre.com</link>
	<description></description>
	<lastBuildDate>Fri, 04 Jun 2010 07:15:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mephisto 0.8 (Drax) Quick Install</title>
		<link>http://meseretgebre.com/archives/mephisto-08-drax-quick-install/</link>
		<comments>http://meseretgebre.com/archives/mephisto-08-drax-quick-install/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 04:10:43 +0000</pubDate>
		<dc:creator>mez</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[Mephisto]]></category>

		<guid isPermaLink="false">http://meseretgebre.com/?p=51</guid>
		<description><![CDATA[If you are not a programmer, I recommend you use a different blogging engine, because even after the install is a success. You&#8217;ll still need to edit the template of your choice to get it just right. I am still not done editing this template. Installing  Mephisto 0.8 (Drax)  is not exactly the [...]]]></description>
			<content:encoded><![CDATA[<p>If you are not a programmer, I recommend you use a different blogging engine, because even after the install is a success. You&#8217;ll still need to edit the template of your choice to get it just right. I am still not done editing this template. Installing  Mephisto 0.8 (Drax)  is not exactly the easiest thing to do. However, I have managed to do it twice in the last month. So here is the process to save hackers out there some time. There are a couple of requirements that you will need before proceeding with the install.</p>
<ol>
<li> Rails 2.0.2</li>
<li> tzinfo (I have 0.3.9)</li>
<li> At least rake 0.8.1</li>
</ol>
<p><strong>Installing Rails 2.0.2 </strong></p>
<p>This should also install rake for you. Just in case I have the command below.</p>
<pre class="brush: bash">
sudo gem install rails -v=2.0.2
</pre>
<p><strong>Installing tzinfo </strong></p>
<pre class="brush: bash">
sudo gem install tzinfo
</pre>
<p><strong>Installing Rake</strong></p>
<pre class="brush: bash">
sudo gem install rake
</pre>
<p>From here change directory to the home of your rail applications.<br />
Now run the command:</p>
<pre class="brush: bash">
sudo wget http://github.com/technoweenie/mephisto/tarball/master.tar.gz
sudo tar -xvf technoweenie-mephisto-90e2cc253d94e2e544bc8b21f361c7360c1e9baa.tar.gz
sudo mv technoweenie-mephisto-90e2cc253d94e2e544bc8b21f361c7360c1e9baa blog
</pre>
<p>The last command simply renames the directory to something more readable. Here I renamed it to &#8220;blog&#8221;. This will be the mephisto root directory. OK! You now have all the things to need to start the installation. From here on is where I ran into all the trouble. Not to worry, I ironed out all the kinks so you should be OK!</p>
<p><strong>Installation in 8 easy steps</strong></p>
<ol>
<li> Create a database named mephisto (or one of your choosing).If you are running mysql, you can do this at the command prompt. This assumes your localhost root does not have a password.</li>
<pre class="brush: bash">
mysql -u root
mysql&gt; create database mephisto;
</pre>
<li>Copy config/database.example.yml to config/database.yml<br />
Just copy and past the following command from the config directory.</li>
<pre class="brush: bash">
sudo mv database.example.yml database.yml
</pre>
<li>Edit database.yml and set your database credentials.</li>
<li>This step is important. Edit config/environment.rb<br />
and append the following line. This step will save you trouble when running the rake db:bootstrap command two steps down.</li>
<pre class="brush: bash">
RAILS_GEM_VERSION = &#039;2.0.2&#039; unless defined? RAILS_GEM_VERSION
</pre>
<li>Time to update your boot.rb file. From your mephisto root directory, run the following command.</li>
<pre class="brush: bash">
rake rails:update
</pre>
<li>OK! Time for the big moment! Are you ready? It&#8217;s time to bootstrap your database. Run the following command from your mephisto root directory.</li>
<pre class="brush: bash">
rake db:bootstrap RAILS_ENV=production
</pre>
<li>If you got to this step without troubles, then consider this a big win! The next step is to deploy mephisto, I recommend mod_rails.</li>
<li>Last step! Login to your administration at http://domain.com/admin with the username: admin and password: test</li>
</ol>
<p>That is all there is to it. I hope everything went OK for you. Any questions or comments are welcomed.</p>
]]></content:encoded>
			<wfw:commentRss>http://meseretgebre.com/archives/mephisto-08-drax-quick-install/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails 2.0 Patrials and Collections part2</title>
		<link>http://meseretgebre.com/archives/rails-20-patrials-and-collections-part2/</link>
		<comments>http://meseretgebre.com/archives/rails-20-patrials-and-collections-part2/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 03:40:13 +0000</pubDate>
		<dc:creator>mez</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[partials]]></category>

		<guid isPermaLink="false">http://meseretgebre.com/?p=29</guid>
		<description><![CDATA[In part one of this article we went over how to create and use partials. Part two will take what we learned from part one and see how we can use collections to make partials even more useful. We&#8217;ll see how you can set additional local variables in your partial. This article is short and [...]]]></description>
			<content:encoded><![CDATA[<p>In part one of this article we went over how to create and use partials. Part two will take what we learned from part one and see how we can use collections to make partials even more useful. We&#8217;ll see how you can set additional local variables in your partial. This article is short and assume you have read part1 of this article.</p>
<p><strong>Outline for this article</strong></p>
<ol>
<li>How do we set local variables in Rails Partials?</li>
<li>Using Rails Partials in a loop?</li>
<li>Is there a point to the Spacer Template in Rails Partials?</li>
</ol>
<p><strong>How do we set local variables in Rails Partials? </strong><br />
Ok, so we know that we can pass in an object to a partial with the</p>
<pre class="brush: python">
 <img src='http://meseretgebre.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> bject
</pre>
<p>symbol. Great, but what if you want to use more variables in the partial.<br />
This can be done using the</p>
<pre class="brush: python">
:locals
</pre>
<p>symbol in the render helper. For example if go back to the example given in part1</p>
<pre class="brush: python">
&lt;%= render :partial =&gt; &quot;shared/testpartial&quot;, <img src='http://meseretgebre.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> bject =&gt; @name , :locals =&gt; {:testvar =&gt; @any_object_you_want } %&gt;;
</pre>
<p>Just make sure you know the name of the local variables you are setting.</p>
<p><strong>Using Rails Partials in a loop?</strong><br />
With partials we can format create modular views. Sometimes you&#8217;ll find the need to<br />
render a partial many time over. On way you can do this is to run the partial in a for loop.<br />
Rails has a shortcut for this. You can use the symbol</p>
<pre class="brush: python">
:collection
</pre>
<p>The symbol takes a collection of objects that the partial takes! The example from <a href="http://meseretgebre.com/?p=26">part1</a> took a string object. So to use the collection we can pass it a list of string objects like the following</p>
<pre class="brush: python">
&lt;%= render :partial =&gt; &quot;shared/testpartial&quot;,
:collection =&gt; %w{ Mez Adam Azmara John} %&gt;;
</pre>
<p>This is a very useful feature, if used correctly your views show look clean. This makes maintenance<br />
of code very manageable and enjoyable.</p>
<p><strong>Is there a point to the Spacer Template in Rails Partials?</strong><br />
There is a option the render helper can take called</p>
<pre class="brush: python">
:spacer_template
</pre>
<p>It lets you specify a template that will be rendered between each of the elements in the collection.<br />
Basically, it renders another parital. Here is how to use it.</p>
<pre class="brush: python">
&lt;%= render :partial =&amp;gt; &quot;shared/testpartial&quot;,
:collection =&gt; %w{ Mez Adam Azmara John},
:spacer_template =&gt; &quot;shared/another_partial&quot; %&gt;;
</pre>
<p>Note, this assumes you have a &#8220;_another_partial.html.erb&#8221; handy. My thinking on this is a little off. I am not sure if you really need to define another partial to display in between partials. Why not just define the content of the spacer template in the first partial? Give some good examples if you think of any!</p>
<p>That concludes this article. I hope you enjoyed it!</p>
]]></content:encoded>
			<wfw:commentRss>http://meseretgebre.com/archives/rails-20-patrials-and-collections-part2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails 2.0 Patrials and Collections part1</title>
		<link>http://meseretgebre.com/archives/rails-20-patrials-and-collections-part1/</link>
		<comments>http://meseretgebre.com/archives/rails-20-patrials-and-collections-part1/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 03:29:37 +0000</pubDate>
		<dc:creator>mez</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[partials]]></category>

		<guid isPermaLink="false">http://meseretgebre.com/?p=26</guid>
		<description><![CDATA[Often in web applications, the same data is displayed in more than one location. Usually this is done by copying code between different template pages. Using Rails we can avoid this and remain true to the Rails principles of &#8220;never repeating ourselves&#8221;. This is accomplished by using Rails partials.
In part one of this article we&#8217;ll [...]]]></description>
			<content:encoded><![CDATA[<p>Often in web applications, the same data is displayed in more than one location. Usually this is done by copying code between different template pages. Using Rails we can avoid this and remain true to the Rails principles of &#8220;never repeating ourselves&#8221;. This is accomplished by using Rails partials.</p>
<p>In part one of this article we&#8217;ll see how to create and use partials. Part two will take what we learned from part one and see how we can use collections to make partials even more useful. Note, more info can be found from the book &#8220;Agile Web Development with Rails&#8221; in the chapter that deals with ActionView. </p>
<p><strong>Outline for this article</strong></p>
<ol>
<li> What the heck are Rails Partials?</li>
<li> How do we create Rails Partials?</li>
<li> How to use Rails Partials?</li>
</ol>
<p><strong>What the heck are Rails Partials?</strong><br />
Rails Partials are basically subroutines in their own right. You can use them many times and in many different templates. If you want, you can even pass in objects to render as parameters. A partial template looks just like a regular templates in Rails with the exception of the name of the file containing the partial. The name of the file containing the template code must start with an underscore character.</p>
<p><strong>How do we create a Rails Partials?</strong><br />
I learn best by examples. So that&#8217;s what we&#8217;ll do here! Let take a simple example that serves no purpose but to learn from. Lets create a simple partial template that will take a string object and simply render the string. In a file named &#8220;_testpartial.html.erb&#8221;.</p>
<p>Some background information to keep in mind. you might be wondering where do you store this partial file? Well that depends. If you want to use this partials in views from multiple controllers, then what I like to do is create a folder called &#8220;shared&#8221; in the views directory. So go ahead and do that now. Are you done yet? Ok, lets keep moving.</p>
<pre class="brush: python">
Hello, &lt;%=testpartial%&gt;;
</pre>
<p>Keep in mind that the partial in this example expects a string object. Well now you might be wondering how does the partial know the name of the object being passed in? It uses the name of the partial as a variable name. Since this simple partial is called &#8220;_testpartial.html.erb&#8221;, we can use the variable &#8220;testpartial&#8221;. Now that we have this partial setup and created lets go and use it!</p>
<p><strong>How to use Rails Partials?</strong><br />
Using a partial is really simple. You can do this in two places. The first way is in the controller like the following.</p>
<pre class="brush: python">
def index
@name = &quot;Meseret Gebre&quot;
render :partial =&amp;gt; &quot;shared/testpartial&quot;, <img src='http://meseretgebre.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> bject =&amp;gt; @name
end
</pre>
<p>The second way is in the view. For example if we setup the instance variable in the controller like the following.</p>
<pre class="brush: python">
def index
#var to be used in view.
@name = &quot;Meseret Gebre&quot;
end
</pre>
<p>Then in the view &#8220;index.rhtml&#8221; we can render the partial by placing the following code somewhere in the view.</p>
<pre class="brush: python">
&lt;%=render :partial =&gt; &quot;shared/testpartial&quot;, <img src='http://meseretgebre.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> bject =&gt; @name%&gt;;
</pre>
<p>Thats Rails partials in a nutshell. Remember in <a href="http://meseretgebre.com/?p=29">part2</a> of this article, we&#8217;ll look at using partials to render a collections of objects! I hope you learned something cool here and remember to never repeat yourself! Any questions or comments are welcomed!</p>
]]></content:encoded>
			<wfw:commentRss>http://meseretgebre.com/archives/rails-20-patrials-and-collections-part1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
