<?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/"
	>

<channel>
	<title>ROR Blog</title>
	<atom:link href="http://blog.nabia.de/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.nabia.de</link>
	<description>A Ruby on Rails Blog</description>
	<pubDate>Tue, 31 Mar 2009 07:41:12 +0000</pubDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ActiveScaffold Error</title>
		<link>http://blog.nabia.de/?p=118</link>
		<comments>http://blog.nabia.de/?p=118#comments</comments>
		<pubDate>Fri, 27 Mar 2009 10:19:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[plugins]]></category>

		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://blog.nabia.de/?p=118</guid>
		<description><![CDATA[Wie viele von euch da draußen benutze ich auch activescaffold. Auf mein Windows Desktop Rechner (Rails 2.2.2) hatte ich keine Probleme. Auf meinen Server (auch Rails 2.2.2) tauche merkwürdigerweise, wenn ich ein neues Element erzeugen wollte, folgender Fehler auf: 
&#8216;Request Failed (code 500, Internal Error)&#8217; &#8212; ActionView::TemplateError (undefined method `find_template&#8217;&#8230;
Ich habe hier eine Lösung für [...]]]></description>
			<content:encoded><![CDATA[<p>Wie viele von euch da draußen benutze ich auch activescaffold. Auf mein Windows Desktop Rechner (Rails 2.2.2) hatte ich keine Probleme. Auf meinen Server (auch Rails 2.2.2) tauche merkwürdigerweise, wenn ich ein neues Element erzeugen wollte, folgender Fehler auf: </p>
<p>&#8216;Request Failed (code 500, Internal Error)&#8217; &#8212; ActionView::TemplateError (undefined method `find_template&#8217;&#8230;</p>
<p>Ich habe <a href="http://code.google.com/p/activescaffold/issues/detail?id=664">hier</a> eine Lösung für das Problem gefunden: </p>
<p>It is need comment method template_exists? from<br />
active_scaffold/lib/extensions/action_view_rendering.rb</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nabia.de/?feed=rss2&amp;p=118</wfw:commentRss>
		</item>
		<item>
		<title>Kalender mit Auswahlmöglichkeit (AJAX)</title>
		<link>http://blog.nabia.de/?p=77</link>
		<comments>http://blog.nabia.de/?p=77#comments</comments>
		<pubDate>Wed, 18 Mar 2009 16:35:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[plugins]]></category>

		<category><![CDATA[ruby on rails]]></category>

		<category><![CDATA[ajax]]></category>

		<category><![CDATA[calendar_date_select]]></category>

		<category><![CDATA[Kalender]]></category>

		<guid isPermaLink="false">http://blog.nabia.de/?p=77</guid>
		<description><![CDATA[Für ein Projekt, vielleicht werde ich es in einen späteren Artikel vorstellen, brauchte ich einen Kalender, bei dem man einen Tag auswählen kann. Zu dem ausgewählten Tag sollten dann bestimmte Informationen angezeigt werden. Natürlich hätte man das Ganze auch mit einer simplen textbox oder die ruby on rails implementierte Lösung date_select, lösen können. Ich denke, [...]]]></description>
			<content:encoded><![CDATA[<p>Für ein Projekt, vielleicht werde ich es in einen späteren Artikel vorstellen, brauchte ich einen Kalender, bei dem man einen Tag auswählen kann. Zu dem ausgewählten Tag sollten dann bestimmte Informationen angezeigt werden. Natürlich hätte man das Ganze auch mit einer simplen textbox oder die ruby on rails implementierte Lösung <em>date_select</em>, lösen können. Ich denke, dass mir die Meisten zu stimmen würden, dass ein Kalender mit Wochentagen und Monaten, in dem man einfach per Mausklick einen Tag auswählen kann, schöner ist.</p>
<p>Ich habe diverse Plugins mir angeschaut und das einzige, welches meinen Anspruch gerecht geworden ist, war <a style="text-decoration: underline; color: #FF0000;" title="calendardateselect" href="http://code.google.com/p/calendardateselect/" target="_blank">calendardateselect</a>!</p>
<h3><strong>Installation:</strong></h3>
<ol>
<li>Installiere das calendar_date_select gem.<br />
<em> sudo gem install calendar_date_select</em></li>
<li>Füge die gem Abhängigkeit zu dem ROR-Projekt hinzu (environment.rb).<br />
<em>config.gem &#8220;calendar_date_select&#8221;</em></li>
<li>Starte das Projekt neu.</li>
<li>Füge folgende Zeile an den Anfang des Views hinzu.

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span>= calendar_date_select_includes <span style="color:#996600;">&quot;red&quot;</span>
  <span style="color:#008000; font-style:italic;"># or &quot;blue&quot;, or &quot;silver&quot;, or nil for the default! %&gt;</span></pre></div></div>

</li>
</ol>
<h3><strong>Einen Kalender im View anzeigen:</strong></h3>
<p>Füge folgende Zeile an die Stelle an die der Kalender angezeigt werden soll hinzu:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span>= calendar_date_select_tag
<span style="color:#996600;">&quot;name_of_variable_of_the_selected_date&quot;</span>,
default_date, <span style="color:#ff3333; font-weight:bold;">:embedded</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p><strong>Screenshot</strong> des Kalenders mit der Einstellung<br />
<em>&lt;%= calendar_date_select_includes &#8220;silver&#8221;%&gt;</em></p>
<p><em><img class="alignnone size-full wp-image-88" title="kalender" src="http://blog.nabia.de/wp-content/uploads/2009/03/kalender.jpg" alt="kalender" width="212" height="227" /><br />
</em></p>
<p>Erklärungen:</p>
<p><em>name_variable_of_the_selected_date </em>in dieser Variable wird der ausgewählte Tag gespeichert. Sie können diese bennen wie Sie möchten.</p>
<p><em> default_date </em>dieser Tag wird beim Aufruf angezeigt. Sie können Ihn auf<em> nil</em> setzten, dann wird der heutige Tag angezeigt.  <em><br />
</em></p>
<h3><strong>Auswahl eines Tages verfolgen:</strong></h3>
<p>Hierzu benutze ich einen Observer, damit ich mitbekomme, wenn ein ander Tag ausgewählt wird.</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span>= <span style="color:#5A0A0A; font-weight:bold;">observe_field</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;name_of_variable_of_the_selected_date&quot;</span>,
<span style="color:#ff3333; font-weight:bold;">:frequency</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">0.25</span>,
<span style="color:#ff3333; font-weight:bold;">:update</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;update_this_part_in_the_view&quot;</span>,
<span style="color:#ff3333; font-weight:bold;">:url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:action_which_should_called_by_change</span> <span style="color:#006600; font-weight:bold;">&#125;</span>,
<span style="color:#ff3333; font-weight:bold;">:with</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;'name_of_variable_of_the_selected_date='+value&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.nabia.de/?feed=rss2&amp;p=77</wfw:commentRss>
		</item>
		<item>
		<title>UNION auf zwei unterschiedliche Tabellen</title>
		<link>http://blog.nabia.de/?p=64</link>
		<comments>http://blog.nabia.de/?p=64#comments</comments>
		<pubDate>Wed, 11 Mar 2009 15:31:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[SQL]]></category>

		<category><![CDATA[SQL UNION zwei tabellen vereinigen ungleiche Anzahl]]></category>

		<guid isPermaLink="false">http://blog.nabia.de/?p=64</guid>
		<description><![CDATA[Mit UNION kann man normalerweise nur zwei Tabellen mit gleicher Form vereinigen. Gleiche Form meint in diesem Fall, dass die beiden Tabellen die gleiche Spaltenanzahl und -namen bzw. zumindest gleiche -typen haben. Mit einem kleinen Trick ist es trotzdem möglich zwei Tabellen zu vereinigen, die ungleiche Spaltenanzahl haben. Hierzu fügt man eine NULL-Spalte mit

NULL AS [...]]]></description>
			<content:encoded><![CDATA[<p>Mit <em><strong>UNION</strong></em> kann man normalerweise nur zwei Tabellen mit gleicher Form vereinigen. Gleiche Form meint in diesem Fall, dass die beiden Tabellen die gleiche Spaltenanzahl und -namen bzw. zumindest gleiche -typen haben. Mit einem kleinen Trick ist es trotzdem möglich zwei Tabellen zu vereinigen, die ungleiche Spaltenanzahl haben. Hierzu fügt man eine <strong><em>NULL</em></strong>-Spalte mit</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AS</span> fehlende_spalte</pre></div></div>

<p> zur Tabelle hinzu.</p>
<p>Hier ein kleines Beispiel:<br />
<strong></strong></p>
<p><em>Tabelle </em><strong>t1</strong><br />
a          | kosten<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
haus   | 30<br />
land    | 80<br />
wald   | 20</p>
<p><em>Tabelle </em><strong>t2</strong><br />
a       |    b     | kosten<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
haus|raum | 10<br />
haus|flur     | 5<br />
wald|baum| 3</p>
<p>Um die beiden Tabellen zu vereinigen genügt folgender SQL-Befehl:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> a<span style="color: #66cc66;">,</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AS</span> b<span style="color: #66cc66;">,</span> kosten <span style="color: #993333; font-weight: bold;">FROM</span> t1
<span style="color: #993333; font-weight: bold;">UNION</span>
<span style="color: #993333; font-weight: bold;">SELECT</span> a<span style="color: #66cc66;">,</span>b<span style="color: #66cc66;">,</span>kosten <span style="color: #993333; font-weight: bold;">FROM</span> t2</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.nabia.de/?feed=rss2&amp;p=64</wfw:commentRss>
		</item>
		<item>
		<title>link_to mit einem Bild</title>
		<link>http://blog.nabia.de/?p=55</link>
		<comments>http://blog.nabia.de/?p=55#comments</comments>
		<pubDate>Mon, 09 Mar 2009 10:58:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://blog.nabia.de/?p=55</guid>
		<description><![CDATA[Folgender Code zeigt ein Bild anstatt eines Textes an:

&#60;%= link_to image_tag&#40;&#34;image.png&#34;, :border=&#62;0&#41;, 
                           :action =&#62; 'edit', :id =&#62; user %&#62;

]]></description>
			<content:encoded><![CDATA[<p>Folgender Code zeigt ein Bild anstatt eines Textes an:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span>= <span style="color:#5A0A0A; font-weight:bold;">link_to</span> <span style="color:#5A0A0A; font-weight:bold;">image_tag</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;image.png&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:border</span><span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>, 
                           <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'edit'</span>, <span style="color:#ff3333; font-weight:bold;">:id</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> user <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.nabia.de/?feed=rss2&amp;p=55</wfw:commentRss>
		</item>
		<item>
		<title>rand(x), array.rand</title>
		<link>http://blog.nabia.de/?p=36</link>
		<comments>http://blog.nabia.de/?p=36#comments</comments>
		<pubDate>Mon, 09 Mar 2009 07:33:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://blog.nabia.de/?p=36</guid>
		<description><![CDATA[rand(x):

rand&#40;x&#41; #liefert eine Zufallszahl (float) &#60; x

array.rand:
Anmerkung: array.rand ist eine Ruby on Rails-Erweiterung.

array = &#91;&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;e&#34;&#93;
random_letter = array.rand #random_letter beinhaltet 
                           #einen Buchstaben (a-e)

]]></description>
			<content:encoded><![CDATA[<p><strong>rand(x):</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">rand</span><span style="color:#006600; font-weight:bold;">&#40;</span>x<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;">#liefert eine Zufallszahl (float) &lt; x</span></pre></div></div>

<p><strong>array.rand:</strong><br />
<em>Anmerkung: array.rand ist eine Ruby on Rails-Erweiterung.</em></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">array</span> = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;a&quot;</span>,<span style="color:#996600;">&quot;b&quot;</span>,<span style="color:#996600;">&quot;c&quot;</span>,<span style="color:#996600;">&quot;d&quot;</span>,<span style="color:#996600;">&quot;e&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
random_letter = <span style="color:#CC0066; font-weight:bold;">array</span>.<span style="color:#CC0066; font-weight:bold;">rand</span> <span style="color:#008000; font-style:italic;">#random_letter beinhaltet </span>
                           <span style="color:#008000; font-style:italic;">#einen Buchstaben (a-e)</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.nabia.de/?feed=rss2&amp;p=36</wfw:commentRss>
		</item>
		<item>
		<title>Nullstellen</title>
		<link>http://blog.nabia.de/?p=33</link>
		<comments>http://blog.nabia.de/?p=33#comments</comments>
		<pubDate>Sun, 08 Mar 2009 17:01:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Ruby-Aufgaben]]></category>

		<guid isPermaLink="false">http://blog.nabia.de/?p=33</guid>
		<description><![CDATA[Unsere erste Rubyprogrammieraufgabe befasst sich mit dem finden von Nullstellen einer Funktion.
Gegeben ist eine Funktion (z.B. f(x) = 5x^3 + 9x^2 + 2x + 3) und ein Intervall [a,b]. Es sollen alle Nullstellen nährungsweise im Intervall gefunden werden. Man erinnere sich, dass eine Nullstelle zwischen zwei Stellen a und b liegt, wenn f(a)*f(b) &#60; 0 [...]]]></description>
			<content:encoded><![CDATA[<p>Unsere erste Rubyprogrammieraufgabe befasst sich mit dem finden von Nullstellen einer Funktion.</p>
<p>Gegeben ist eine Funktion (z.B. f(x) = 5x^3 + 9x^2 + 2x + 3) und ein Intervall [a,b]. Es sollen alle Nullstellen nährungsweise im Intervall gefunden werden. Man erinnere sich, dass eine Nullstelle zwischen zwei Stellen a und b liegt, wenn f(a)*f(b) &lt; 0 ist.</p>
<p>Viel Spaß beim Lösen.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nabia.de/?feed=rss2&amp;p=33</wfw:commentRss>
		</item>
		<item>
		<title>Erster Tag einer Kalenderwoche</title>
		<link>http://blog.nabia.de/?p=9</link>
		<comments>http://blog.nabia.de/?p=9#comments</comments>
		<pubDate>Sun, 08 Mar 2009 11:46:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.nabia.de/?p=9</guid>
		<description><![CDATA[Manchmal ist es notwendig den ersten Tag einer Kalenderwoche zu identifizieren. Ruby liefert schon einige Hilfsmittel hierfür, aber es gibt keine direkte Methode dafür. Hier ist eine Möglichkeit zur Berechnung des ersten Tages (Montag) einer Kalenderwoche:

def week_to_date&#40;week, year&#41;
  date = Date.parse&#40;&#34;01-01-&#34;+year&#41;
  if date.cwday == 1
    x = 0;
  else
    x = 8-date.cwday
  end
    date+x+&#40;7*&#40;week-1&#41;&#41;
 end

]]></description>
			<content:encoded><![CDATA[<p>Manchmal ist es notwendig den ersten Tag einer Kalenderwoche zu identifizieren. Ruby liefert schon einige Hilfsmittel hierfür, aber es gibt keine direkte Methode dafür. Hier ist eine Möglichkeit zur Berechnung des ersten Tages (Montag) einer Kalenderwoche:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> week_to_date<span style="color:#006600; font-weight:bold;">&#40;</span>week, year<span style="color:#006600; font-weight:bold;">&#41;</span>
  date = <span style="color:#CC00FF; font-weight:bold;">Date</span>.<span style="color:#9900CC;">parse</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;01-01-&quot;</span><span style="color:#006600; font-weight:bold;">+</span>year<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">if</span> date.<span style="color:#9900CC;">cwday</span> == <span style="color:#006666;">1</span>
    x = <span style="color:#006666;">0</span>;
  <span style="color:#9966CC; font-weight:bold;">else</span>
    x = <span style="color:#006666;">8</span><span style="color:#006600; font-weight:bold;">-</span>date.<span style="color:#9900CC;">cwday</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
    date<span style="color:#006600; font-weight:bold;">+</span>x<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">7</span><span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#40;</span>week<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
 <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.nabia.de/?feed=rss2&amp;p=9</wfw:commentRss>
		</item>
	</channel>
</rss>
