<?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>Rails and Stuff at Abel killed Cain</title>
	<atom:link href="http://www.abelkilledcain.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.abelkilledcain.de</link>
	<description>Ruby on Rails and other Webdevelopment</description>
	<lastBuildDate>Sat, 06 Mar 2010 18:23:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP 5.3 lambda use case</title>
		<link>http://www.abelkilledcain.de/php-5-3-lambda-use-case/</link>
		<comments>http://www.abelkilledcain.de/php-5-3-lambda-use-case/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 18:21:23 +0000</pubDate>
		<dc:creator>inbreed</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.abelkilledcain.de/?p=174</guid>
		<description><![CDATA[i just thought about iterating objects in php.
Since 5.3 supports lambda, i found this quite usefull:
123456789101112131415161718192021class Test &#123;
&#160; &#160; &#160; &#160; public $vals = array&#40;&#41;;

&#160; &#160; &#160; &#160; function __construct&#40;&#41;&#123;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; $this-&#62;vals = range&#40;1,10&#41;;
&#160; &#160; &#160; &#160; &#125;

&#160; &#160; &#160; &#160; // the hooray goes here!
&#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>i just thought about iterating objects in php.</p>
<p>Since 5.3 supports lambda, i found this quite usefull:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">class</span> Test <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$vals</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">vals</span> <span style="color: #339933;">=</span> <span style="color: #990000;">range</span><span style="color: #009900;">&#40;</span>1<span style="color: #339933;">,</span>10<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// the hooray goes here!</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #990000;">each</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$function</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">vals</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$element</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$function</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$element</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000088;">$t</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Test<span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//the real hooray-part:</span><br />
<span style="color: #000088;">$t</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">each</span><span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$e</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Hi, i am element <span style="color: #006699; font-weight: bold;">$e</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Works! :)<br />
<span id="more-174"></span><br />
Ah and yes, for idiots not knowing what happens on execution:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ php test.php <br />
Hi, i am element 1<br />
Hi, i am element 2<br />
Hi, i am element 3<br />
Hi, i am element 4<br />
Hi, i am element 5<br />
Hi, i am element 6<br />
Hi, i am element 7<br />
Hi, i am element 8<br />
Hi, i am element 9<br />
Hi, i am element 10</div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.abelkilledcain.de/php-5-3-lambda-use-case/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Have fun with Internet Exploider 6.0</title>
		<link>http://www.abelkilledcain.de/have-fun-with-internet-exploider-6-0/</link>
		<comments>http://www.abelkilledcain.de/have-fun-with-internet-exploider-6-0/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 17:38:56 +0000</pubDate>
		<dc:creator>inbreed</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[workaround]]></category>

		<guid isPermaLink="false">http://www.abelkilledcain.de/?p=168</guid>
		<description><![CDATA[Building Websites is fun!
Having IE6 Users sucks instead!
Get rid of them by pasting the following code into your document-head.
&#60;!&#8211;[if IE 6]&#62;
&#60;script type=&#8221;text/javascript&#8221;&#62;
alert(&#8221;No IE 6! Thanks!&#8221;);
document.write(&#8217;&#60;style&#62;*{position:relative}&#60;/style&#62;&#60;table&#62;&#60;input&#62;&#60;/table&#62;&#8217;)
&#60;/script&#62;
&#60;![endif]&#8211;&#62;
IE 6 will crash after asking the user not to use it!
]]></description>
			<content:encoded><![CDATA[<p>Building Websites is fun!</p>
<p>Having IE6 Users sucks instead!</p>
<p>Get rid of them by pasting the following code into your document-head.</p>
<p>&lt;!&#8211;[if IE 6]&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
alert(&#8221;No IE 6! Thanks!&#8221;);<br />
document.write(&#8217;&lt;style&gt;*{position:relative}&lt;/style&gt;&lt;table&gt;&lt;input&gt;&lt;/table&gt;&#8217;)<br />
&lt;/script&gt;<br />
&lt;![endif]&#8211;&gt;</p>
<p>IE 6 will crash after asking the user not to use it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.abelkilledcain.de/have-fun-with-internet-exploider-6-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>changing behavior of on_error_message and field errors</title>
		<link>http://www.abelkilledcain.de/changing-behavior-of-on_error_message-and-field-errors/</link>
		<comments>http://www.abelkilledcain.de/changing-behavior-of-on_error_message-and-field-errors/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 16:30:25 +0000</pubDate>
		<dc:creator>inbreed</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[input]]></category>

		<guid isPermaLink="false">http://www.abelkilledcain.de/?p=153</guid>
		<description><![CDATA[Ruby on Rails provides a nice way to display error_messages; just by adding form.error_messages you get a nice overview of all your errors.
But i prefer to have it in different ways, so i 1) dont want the on_error_message-output to be a div element, 2) further i want to give each input field having bad content [...]]]></description>
			<content:encoded><![CDATA[<p>Ruby on Rails provides a nice way to display error_messages; just by adding form.error_messages you get a nice overview of all your errors.</p>
<p>But i prefer to have it in different ways, so i 1) dont want the on_error_message-output to be a div element, 2) further i want to give each input field having bad content to be marked &#8211; by adding an error-class to that specific element for example.</p>
<p>Since i had to figure it out, here are the results for changing both.</p>
<p><strong>1) different element instead of a div at on_error_message?</strong><br />
<span id="more-153"></span></p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">module</span> SpanOnErrorMessages &nbsp;<span style="color:#008000; font-style:italic;">#rename it properly </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># File actionpack/lib/action_view/helpers/active_record_helper.rb, line 109</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> error_message_on<span style="color:#006600; font-weight:bold;">&#40;</span>object, method, <span style="color:#006600; font-weight:bold;">*</span>args<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; options = args.<span style="color:#9900CC;">extract_options</span>!<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">unless</span> args.<span style="color:#9900CC;">empty</span>?<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#6666ff; font-weight:bold;">ActiveSupport::Deprecation</span>.<span style="color:#9900CC;">warn</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'error_message_on takes an option hash instead of separate '</span> <span style="color:#006600; font-weight:bold;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#996600;">'prepend_text, append_text, and css_class arguments'</span>, <span style="color:#CC0066; font-weight:bold;">caller</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:prepend_text</span><span style="color:#006600; font-weight:bold;">&#93;</span> = args<span style="color:#006600; font-weight:bold;">&#91;</span>0<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#996600;">''</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:append_text</span><span style="color:#006600; font-weight:bold;">&#93;</span> = args<span style="color:#006600; font-weight:bold;">&#91;</span>1<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#996600;">''</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:css_class</span><span style="color:#006600; font-weight:bold;">&#93;</span> = args<span style="color:#006600; font-weight:bold;">&#91;</span>2<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#996600;">'formError'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; options.<span style="color:#9900CC;">reverse_merge</span>!<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:prepend_text</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">''</span>, <span style="color:#ff3333; font-weight:bold;">:append_text</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">''</span>, <span style="color:#ff3333; font-weight:bold;">:css_class</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'formError'</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>obj = <span style="color:#006600; font-weight:bold;">&#40;</span>object.<span style="color:#9900CC;">respond_to</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:errors</span><span style="color:#006600; font-weight:bold;">&#41;</span> ? object : instance_variable_get<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;@#{object}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> <span style="color:#006600; font-weight:bold;">&#40;</span>errors = obj.<span style="color:#9900CC;">errors</span>.<span style="color:#9900CC;">on</span><span style="color:#006600; font-weight:bold;">&#40;</span>method<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; content_tag<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;span&quot;</span>, &nbsp;<span style="color:#008000; font-style:italic;">#rewritten to span! hooray!</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#996600;">&quot;#{options[:prepend_text]}#{ERB::Util.html_escape(errors.is_a?(Array) ? errors.first : errors)}#{options[:append_text]}&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :<span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:css_class</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#996600;">''</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span> &nbsp; &nbsp; &nbsp;<br />
<br />
<span style="color:#008000; font-style:italic;">#now telling ActionView to use it!</span><br />
<span style="color:#6666ff; font-weight:bold;">ActionView::Base</span>.<span style="color:#9900CC;">send</span> :<span style="color:#9966CC; font-weight:bold;">include</span>, SpanOnErrorMessages</div></td></tr></tbody></table></div>
<p>there we go, thats it! have fun!</p>
<p>If you need, set the element as a hash-paramter to have this more dynamic.</p>
<p>Okay now thats pretty! how about having:<br />
<strong>2) adding an error-class to the bad input elements:</strong></p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;">#environment.rb</span><br />
<span style="color:#6666ff; font-weight:bold;">ActionView::Base</span>.<span style="color:#9900CC;">field_error_proc</span> = <span style="color:#CC0066; font-weight:bold;">Proc</span>.<span style="color:#9900CC;">new</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>html_tag, instace_tag<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; error_class = <span style="color:#996600;">&quot;error&quot;</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> html_tag =~ <span style="color:#006600; font-weight:bold;">/&lt;</span><span style="color:#006600; font-weight:bold;">&#40;</span>input<span style="color:#006600; font-weight:bold;">|</span>textarea<span style="color:#006600; font-weight:bold;">|</span>select<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#91;</span>^<span style="color:#006600; font-weight:bold;">&gt;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+</span><span style="color:#9966CC; font-weight:bold;">class</span>=<span style="color:#006600; font-weight:bold;">/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; style_attribute = html_tag =~ <span style="color:#006600; font-weight:bold;">/</span><span style="color:#9966CC; font-weight:bold;">class</span>=<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'&quot;]/ &nbsp; #'</span>my wordpress colors wierd<br />
&nbsp; &nbsp; &nbsp; &nbsp; html_tag.<span style="color:#9900CC;">insert</span><span style="color:#006600; font-weight:bold;">&#40;</span>style_attribute <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">7</span>, <span style="color:#996600;">&quot;#{error_class} &quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">elsif</span> html_tag =~ <span style="color:#006600; font-weight:bold;">/&lt;</span><span style="color:#006600; font-weight:bold;">&#40;</span>input<span style="color:#006600; font-weight:bold;">|</span>textarea<span style="color:#006600; font-weight:bold;">|</span>select<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; first_whitespace = html_tag =~ <span style="color:#006600; font-weight:bold;">/</span>\s<span style="color:#006600; font-weight:bold;">/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; html_tag<span style="color:#006600; font-weight:bold;">&#91;</span>first_whitespace<span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot; class=<span style="color:#000099;">\&quot;</span>#{error_class}<span style="color:#000099;">\&quot;</span> &quot;</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; html_tag<br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></td></tr></tbody></table></div>
<p>Thats fine! now a wrong input should look like:<br />
&lt;input<strong> class=&#8221;error&#8221; </strong>id=&#8221;user_email&#8221; &#8230; type=&#8221;text&#8221; value=&#8221;just@wrong&#8221;&gt;</p>
<p>Hope you can take use of that? tell me! :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.abelkilledcain.de/changing-behavior-of-on_error_message-and-field-errors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>more detailed logging information in Rails</title>
		<link>http://www.abelkilledcain.de/more-detailed-logging-information-in-rails/</link>
		<comments>http://www.abelkilledcain.de/more-detailed-logging-information-in-rails/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 11:22:29 +0000</pubDate>
		<dc:creator>inbreed</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[details]]></category>
		<category><![CDATA[Kernel]]></category>
		<category><![CDATA[logging]]></category>

		<guid isPermaLink="false">http://www.abelkilledcain.de/?p=145</guid>
		<description><![CDATA[Rails logging methods are wonderful for development.
Indeed, they often suck when you want to inspect objects or cascaded objects. So here is a codesnipped that helps you inspect any kind of any object in rails, deeply and detailed.
as a new lib-file or, just as i do, in application_controller.rb, add the follogwing code:

1234567891011require 'pp'
require 'stringio'

module Kernel
&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Rails logging methods are wonderful for development.</p>
<p>Indeed, they often suck when you want to inspect objects or cascaded objects. So here is a codesnipped that helps you inspect any kind of any object in rails, deeply and detailed.</p>
<p>as a new lib-file or, just as i do, in application_controller.rb, add the follogwing code:</p>
<p><span id="more-145"></span></p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'pp'</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'stringio'</span><br />
<br />
<span style="color:#9966CC; font-weight:bold;">module</span> <span style="color:#CC00FF; font-weight:bold;">Kernel</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> pp_s<br />
&nbsp; &nbsp; &nbsp; &nbsp; s = <span style="color:#CC00FF; font-weight:bold;">StringIO</span>.<span style="color:#9900CC;">new</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; PP.<span style="color:#9900CC;">pp</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">self</span>, s<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; s.<span style="color:#9900CC;">rewind</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; s.<span style="color:#9900CC;">read</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></td></tr></tbody></table></div>
<p>now anywhere in the code, lets say you want to inspect a model, or a hash, or a parameter of any unknown type:</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; logger.<span style="color:#9900CC;">warn</span> var_of_any_kind.<span style="color:#9900CC;">pp_s</span> <span style="color:#008000; font-style:italic;">#or use .info</span></div></td></tr></tbody></table></div>
<p>here is an example from irb:</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#006600; font-weight:bold;">&gt;&gt;</span> User.<span style="color:#9900CC;">last</span>.<span style="color:#9900CC;">pp_s</span><br />
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;#&lt;User id: 918984, email: <span style="color:#000099;">\&quot;</span>foo@baz.net<span style="color:#000099;">\&quot;</span>, crypted_password: <span style="color:#000099;">\&quot;</span>e8878b6c722ec64b921be4c98765431263ebe813293a6c995fe88...<span style="color:#000099;">\&quot;</span>, password_salt: <span style="color:#000099;">\&quot;</span>jfDuRTvSomfg<br />
4Q6sCjhNm<span style="color:#000099;">\&quot;</span>, persistence_token: <span style="color:#000099;">\&quot;</span>464af1170bf8b1302ea3f108e03ed5ff3a0568417b084af27ef...<span style="color:#000099;">\&quot;</span>, &nbsp;login_count: 2, created_at: <span style="color:#000099;">\&quot;</span>2010-02-01 11:24:16<span style="color:#000099;">\&quot;</span>, updated_at: <span style="color:#000099;">\&quot;</span>2010-02-01 11:40:40<span style="color:#000099;">\&quot;</span>, newsletter: <span style="color:#000099;">\&quot;</span>0<span style="color:#000099;">\&quot;</span>&gt;<span style="color:#000099;">\n</span>&quot;</span><br />
<span style="color:#006600; font-weight:bold;">&gt;&gt;</span> User.<span style="color:#9900CC;">pp_s</span><br />
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;User(id: integer, email: string, crypted_password: string, password_salt: string, persistence_token: string, login_count: integer, created_at: datetime, updated_at: datetime, newsletter: integer)<span style="color:#000099;">\n</span>&quot;</span><br />
<span style="color:#006600; font-weight:bold;">&gt;&gt;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.abelkilledcain.de/more-detailed-logging-information-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>7 Ruby Tips for using Rails</title>
		<link>http://www.abelkilledcain.de/7-ruby-tips-for-using-rails/</link>
		<comments>http://www.abelkilledcain.de/7-ruby-tips-for-using-rails/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 21:30:08 +0000</pubDate>
		<dc:creator>inbreed</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[hints]]></category>
		<category><![CDATA[tipps]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://www.abelkilledcain.de/?p=131</guid>
		<description><![CDATA[Here is a small collection of Tips and Tricks for Ruby in association to Rails.
I will paste some irb-logs, displaying all results.
1. Format decimals or text quickly 

In order to display amounts or leading zeros:
12345678910111213141516&#62;&#62; &#34;%.2f&#34; % 49.4
=&#62; &#34;49.40&#34;
&#62;&#62; &#34;%03d&#34; % 1
=&#62; &#34;001&#34;

# even text:

&#62;&#62; msg = &#34;Welcome, %s&#34;;
?&#62; msg % &#34;peter&#34;
=&#62; &#34;Welcome, peter&#34;

# even [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a small collection of Tips and Tricks for Ruby in association to Rails.</p>
<p>I will paste some irb-logs, displaying all results.<br />
<strong>1. Format decimals or text quickly </strong><br />
<span id="more-131"></span><br />
In order to display amounts or leading zeros:</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&gt;&gt; &quot;%.2f&quot; % 49.4<br />
=&gt; &quot;49.40&quot;<br />
&gt;&gt; &quot;%03d&quot; % 1<br />
=&gt; &quot;001&quot;<br />
<br />
# even text:<br />
<br />
&gt;&gt; msg = &quot;Welcome, %s&quot;;<br />
?&gt; msg % &quot;peter&quot;<br />
=&gt; &quot;Welcome, peter&quot;<br />
<br />
# even cooler<br />
<br />
<br />
&gt;&gt; &quot;<span style="color:#006600; font-weight:bold;">&lt;%</span>s<span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006600; font-weight:bold;">%</span>s <span style="color:#006600; font-weight:bold;">&lt;/%</span>s<span style="color:#006600; font-weight:bold;">&gt;</span><span style="color:#996600;">&quot; % %w{strong cool strong}<br />
=&gt; &quot;</span><span style="color:#006600; font-weight:bold;">&lt;</span>strong<span style="color:#006600; font-weight:bold;">&gt;</span> cool <span style="color:#006600; font-weight:bold;">&lt;/</span>strong<span style="color:#006600; font-weight:bold;">&gt;</span><span style="color:#996600;">&quot;</span></div></td></tr></tbody></table></div>
<p>Just keep in mind that the result is a String!</p>
<p><strong>2. Using Hash-Keys</strong></p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#006600; font-weight:bold;">&gt;&gt;</span> test = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#0000FF; font-weight:bold;">true</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Yes&quot;</span>, <span style="color:#0000FF; font-weight:bold;">false</span> <span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#996600;">&quot;No&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span><br />
<span style="color:#006600; font-weight:bold;">&gt;&gt;</span> test<span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#006666;">100</span> == <span style="color:#996600;">&quot;foo&quot;</span> <span style="color:#006600; font-weight:bold;">&#93;</span><br />
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;No&quot;</span></div></td></tr></tbody></table></div>
<p><strong>3. Mass Assignment </strong></p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#006600; font-weight:bold;">&gt;&gt;</span> a,b,c,d = <span style="color:#006666;">1</span>,<span style="color:#006666;">2</span>,<span style="color:#006666;">3</span>,<span style="color:#006666;">4</span><br />
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span>, <span style="color:#006666;">2</span>, <span style="color:#006666;">3</span>, <span style="color:#006666;">4</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
<span style="color:#006600; font-weight:bold;">&gt;&gt;</span> a<br />
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">1</span><br />
<span style="color:#006600; font-weight:bold;">&gt;&gt;</span> c<br />
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">3</span><br />
<br />
<br />
<span style="color:#008000; font-style:italic;"># for methonds:</span><br />
<br />
<span style="color:#9966CC; font-weight:bold;">def</span> giveme_five<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">*</span>hand<span style="color:#006600; font-weight:bold;">&#41;</span> &nbsp;<span style="color:#008000; font-style:italic;">#&lt;-- note the *</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#008000; font-style:italic;">#get fingers</span><br />
&nbsp; &nbsp; &nbsp; f1,f2,f3,f4,f5 = hand<br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></td></tr></tbody></table></div>
<p><strong>4.The Ternary Operator</strong><br />
Often its forgotten! Imagine you want to add classes in HAML e.g.</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#006600; font-weight:bold;">&gt;&gt;</span> :<span style="color:#9966CC; font-weight:bold;">class</span><span style="color:#006600; font-weight:bold;">=&gt;</span> current_user ? <span style="color:#996600;">&quot;active&quot;</span> : <span style="color:#0000FF; font-weight:bold;">nil</span></div></td></tr></tbody></table></div>
<p><strong>5. Use ranges!</strong><br />
Instead of if/else hell, you can use:</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#006600; font-weight:bold;">&gt;&gt;</span> <span style="color:#9966CC; font-weight:bold;">case</span> number<br />
<span style="color:#006600; font-weight:bold;">&gt;&gt;</span> &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">when</span> 0..100: <span style="color:#996600;">&quot;small&quot;</span><br />
<span style="color:#006600; font-weight:bold;">&gt;&gt;</span> &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">when</span> 100..200: <span style="color:#996600;">&quot;medium&quot;</span><br />
<span style="color:#006600; font-weight:bold;">&gt;&gt;</span> &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">when</span> 200..300: <span style="color:#996600;">&quot;big&quot;</span><br />
<span style="color:#006600; font-weight:bold;">&gt;&gt;</span> &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">else</span> <span style="color:#996600;">&quot;unbeliveable&quot;</span><br />
<span style="color:#006600; font-weight:bold;">&gt;&gt;</span> <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;medium&quot;</span></div></td></tr></tbody></table></div>
<p><strong>6. Array.join </strong><br />
* followed by a String can be a shorter way to get the result:</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#006600; font-weight:bold;">&gt;&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span>,<span style="color:#006666;">2</span>,<span style="color:#006666;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">*</span> <span style="color:#006666;">2</span><br />
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span>, <span style="color:#006666;">2</span>, <span style="color:#006666;">3</span>, <span style="color:#006666;">1</span>, <span style="color:#006666;">2</span>, <span style="color:#006666;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
<span style="color:#008000; font-style:italic;"># BUT:</span><br />
<span style="color:#006600; font-weight:bold;">&gt;&gt;</span> <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#123;</span>ruby really rocks<span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#006600; font-weight:bold;">*</span> <span style="color:#996600;">&quot; - &quot;</span><br />
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;ruby - really - rocks&quot;</span></div></td></tr></tbody></table></div>
<p>OC it works with numbers as well.</p>
<p><strong>7. Easy Iteration</strong><br />
Imagine a bad class, giving:</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">result = Model.<span style="color:#9900CC;">first</span><br />
<br />
<span style="color:#008000; font-style:italic;"># but sometimes:</span><br />
<br />
result = Model.<span style="color:#9900CC;">several_rows</span></div></td></tr></tbody></table></div>
<p>Iterating these models is just as easy as:</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">*</span>result<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>r<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; &nbsp; ...<br />
<span style="color:#006600; font-weight:bold;">&#125;</span></div></td></tr></tbody></table></div>
<p>Hope this helps someone out.</p>
<p>What are your favorite Tips and Hints?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.abelkilledcain.de/7-ruby-tips-for-using-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sortable Tables with Ruby on Rails and Ajax</title>
		<link>http://www.abelkilledcain.de/sortable-tables-with-ruby-on-rails-and-ajax/</link>
		<comments>http://www.abelkilledcain.de/sortable-tables-with-ruby-on-rails-and-ajax/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 18:10:05 +0000</pubDate>
		<dc:creator>inbreed</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[haml]]></category>
		<category><![CDATA[sortable]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.abelkilledcain.de/?p=127</guid>
		<description><![CDATA[This is more like a rather small hint, describing how to make tables sortable in rails.
Just like ryan bates shows in his rails casts, there is a similar way to sort tables, instead of lists.
Here the example-code how to make the tables sortable:

12345678910- # this is haml-code! can be done in erb as well..
%table
&#160; %tbody&#123;:id=&#62;&#34;products&#34;&#125;
&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>This is more like a rather small hint, describing how to make tables sortable in rails.</p>
<p>Just like ryan bates shows in his rails casts, there is a similar way to sort tables, instead of lists.</p>
<p>Here the example-code how to make the tables sortable:<br />
<span id="more-127"></span></p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#006600; font-weight:bold;">-</span> <span style="color:#008000; font-style:italic;"># this is haml-code! can be done in erb as well..</span><br />
<span style="color:#006600; font-weight:bold;">%</span>table<br />
&nbsp; <span style="color:#006600; font-weight:bold;">%</span>tbody<span style="color:#006600; font-weight:bold;">&#123;</span>:id<span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#996600;">&quot;products&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">-</span><span style="color:#9966CC; font-weight:bold;">for</span> product <span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#0066ff; font-weight:bold;">@products</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">%</span>tr<span style="color:#006600; font-weight:bold;">&#123;</span>:id<span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#996600;">&quot;product_#{product.id}&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">%</span>td=product.<span style="color:#9900CC;">name</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">-</span><span style="color:#008000; font-style:italic;">#.. more hamlcode</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">-</span><span style="color:#008000; font-style:italic;"># i want a drag-handler, optional</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">%</span>td.<span style="color:#9900CC;">drag_handle</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =image_tag <span style="color:#996600;">&quot;move.gif&quot;</span></div></td></tr></tbody></table></div>
<p>Note: NOT the table has the id, the tbody has, its the actualy tr-s parentnode, ever!<br />
This code actually only builds the table &#8211; important is the id setting of each tr and tbody.</p>
<p>after the table, just add this simple piece:</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">= sortable_element<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'products'</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>:action <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'update_order'</span><span style="color:#006600; font-weight:bold;">&#125;</span>, <span style="color:#ff3333; font-weight:bold;">:handle</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:drag_handle</span>, <span style="color:#ff3333; font-weight:bold;">:tag</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:tr</span><span style="color:#006600; font-weight:bold;">&#41;</span></div></td></tr></tbody></table></div>
<p>Note: the :tag symbol now points to the tr, default is li.</p>
<p>So far, saving the sorted rows is just like railscasts shows:</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;"># routes.rb</span><br />
<span style="color:#008000; font-style:italic;"># currently in admin-namespace..</span><br />
admin.<span style="color:#9900CC;">resources</span> <span style="color:#ff3333; font-weight:bold;">:products</span>, <span style="color:#ff3333; font-weight:bold;">:collection</span><span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#006600; font-weight:bold;">&#123;</span>:update_order <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:post</span><span style="color:#006600; font-weight:bold;">&#125;</span><br />
<br />
<span style="color:#008000; font-style:italic;"># product_controller</span><br />
<span style="color:#9966CC; font-weight:bold;">def</span> update_order<br />
&nbsp; &nbsp; params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:products</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">each_with_index</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>id,index<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; &nbsp; Product.<span style="color:#9900CC;">update_all</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'position=?'</span>, index<span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'id=?'</span>, id<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; render <span style="color:#ff3333; font-weight:bold;">:nothing</span><span style="color:#006600; font-weight:bold;">=&gt;</span>true<br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></td></tr></tbody></table></div>
<p>Dont forget to include scriptacolous in your layouts.<br />
Hope this helps anyone!</p>
<p>Original Podcast by Ryan Bates:<br />
<a href="http://railscasts.com/episodes/147-sortable-lists" target="_blank">Sortable Lists</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.abelkilledcain.de/sortable-tables-with-ruby-on-rails-and-ajax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Will_Paginate w/o next or previous buttons</title>
		<link>http://www.abelkilledcain.de/rails-will_paginate-wo-next-or-previous-buttons/</link>
		<comments>http://www.abelkilledcain.de/rails-will_paginate-wo-next-or-previous-buttons/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 12:45:38 +0000</pubDate>
		<dc:creator>inbreed</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[pagination]]></category>

		<guid isPermaLink="false">http://www.abelkilledcain.de/?p=123</guid>
		<description><![CDATA[I wanted to have a rather simple pagination without next and previous buttons (yah, the post title told you, eh?).
However, did not find any option to deal with it. But Will_Paginate provides a nice way to overwrite the link renderer in order to have full customization.
So i created the following:

12345678910class PaginationListLinkRenderer &#60; WillPaginate::LinkRenderer
&#160; 
&#160; def [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to have a rather simple pagination without next and previous buttons (yah, the post title told you, eh?).</p>
<p>However, did not find any option to deal with it. But Will_Paginate provides a nice way to overwrite the link renderer in order to have full customization.</p>
<p>So i created the following:<br />
<span id="more-123"></span></p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">class</span> PaginationListLinkRenderer <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">WillPaginate::LinkRenderer</span><br />
&nbsp; <br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> to_html<br />
&nbsp; &nbsp; links = <span style="color:#0066ff; font-weight:bold;">@options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:page_links</span><span style="color:#006600; font-weight:bold;">&#93;</span> ? windowed_links : <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
&nbsp; &nbsp; links.<span style="color:#9900CC;">unshift</span><span style="color:#006600; font-weight:bold;">&#40;</span>page_link_or_span<span style="color:#006600; font-weight:bold;">&#40;</span>@collection.<span style="color:#9900CC;">previous_page</span>, <span style="color:#996600;">'previous'</span>, <span style="color:#0066ff; font-weight:bold;">@options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:previous_label</span><span style="color:#006600; font-weight:bold;">&#93;</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;">if</span> options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:do_prev</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
&nbsp; &nbsp; links.<span style="color:#9900CC;">push</span><span style="color:#006600; font-weight:bold;">&#40;</span>page_link_or_span<span style="color:#006600; font-weight:bold;">&#40;</span>@collection.<span style="color:#9900CC;">next_page</span>, <span style="color:#996600;">'next'</span>, <span style="color:#0066ff; font-weight:bold;">@options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:next_label</span><span style="color:#006600; font-weight:bold;">&#93;</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;">if</span> options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:do_next</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
&nbsp; &nbsp; html = links.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>@options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:separator</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:container</span><span style="color:#006600; font-weight:bold;">&#93;</span> ? <span style="color:#0066ff; font-weight:bold;">@template</span>.<span style="color:#9900CC;">content_tag</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:div</span>, html, html_attributes<span style="color:#006600; font-weight:bold;">&#41;</span> : html<br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></td></tr></tbody></table></div>
<p>So from now on, using the new class ans renderer, i can add :do_next=>true IF i want to have next/prev links. per default its disabled as you can see.<br />
activate it via</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;">#environment.rb</span><br />
<span style="color:#6666ff; font-weight:bold;">WillPaginate::ViewHelpers</span>.<span style="color:#9900CC;">pagination_options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:renderer</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">'PaginationListLinkRenderer'</span><br />
<span style="color:#008000; font-style:italic;">#or template:</span><br />
will_paginate <span style="color:#0066ff; font-weight:bold;">@foo</span>, <span style="color:#ff3333; font-weight:bold;">:renderer</span><span style="color:#006600; font-weight:bold;">=&gt;</span>PaginationListLinkRenderer</div></td></tr></tbody></table></div>
<p>hf!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.abelkilledcain.de/rails-will_paginate-wo-next-or-previous-buttons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Different route, same path/url calling in Rails</title>
		<link>http://www.abelkilledcain.de/different-route-same-pathurl-calling-in-rails/</link>
		<comments>http://www.abelkilledcain.de/different-route-same-pathurl-calling-in-rails/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 13:35:36 +0000</pubDate>
		<dc:creator>inbreed</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[routes]]></category>
		<category><![CDATA[workaround]]></category>

		<guid isPermaLink="false">http://www.abelkilledcain.de/?p=116</guid>
		<description><![CDATA[I had the following problem to solve using rails:

Having 2 Subdomains, www and clients
a client always has a path-prefix to use google analytics for each of this subdirs. so i had the following urls:
www.domain.tld/foo.html  and clients.domain.tld/3kunsdf7w/foo.html
I did not want to have a code on www.
i did not want to alter all tempaltes with new paramters [...]]]></description>
			<content:encoded><![CDATA[<p>I had the following problem to solve using rails:</p>
<ol>
<li>Having 2 Subdomains, www and clients</li>
<li>a client always has a path-prefix to use google analytics for each of this subdirs. so i had the following urls:<br />
www.domain.tld/foo.html  and clients.domain.tld/3kunsdf7w/foo.html</li>
<li>I did not want to have a code on www.</li>
<li>i did not want to alter all tempaltes with new paramters and differen routes</li>
</ol>
<p>Solving this, it was ok for me to duplicate all routes with a client_  prefix using textmate, so i took onl 4 seconds.. but what next, how to tell rails to use the clients_xy_path when i call xy_path?</p>
<p><span id="more-116"></span>To keep it short, i did not find a nice  solution to let rails switch the routes. So i added a get_ to all of these path and urls via sed, also done fast. Now, instead of xy_path(:bar=&gt;&#8217;foo&#8217;) the call was get_xy_path(:bar=&gt;&#8217;foo&#8217;) &#8211; and yes, they really dont exist! :)</p>
<p>my goal:</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">def</span> method<br />
&nbsp; &nbsp; &nbsp; client? ? clientspath : wwwpath <br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></td></tr></tbody></table></div>
<p>my solution:</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">module</span> PathHelper<br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> method_missing<span style="color:#006600; font-weight:bold;">&#40;</span>method_id, <span style="color:#006600; font-weight:bold;">*</span>arguments<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color:#9966CC; font-weight:bold;">if</span> match = <span style="color:#006600; font-weight:bold;">/</span>^get_<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span>_a<span style="color:#006600; font-weight:bold;">-</span>zA<span style="color:#006600; font-weight:bold;">-</span>Z<span style="color:#006600; font-weight:bold;">&#93;</span>\w<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#41;</span>_<span style="color:#006600; font-weight:bold;">&#40;</span>path<span style="color:#006600; font-weight:bold;">|</span>url<span style="color:#006600; font-weight:bold;">&#41;</span>$<span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#9900CC;">match</span><span style="color:#006600; font-weight:bold;">&#40;</span>method_id.<span style="color:#9900CC;">to_s</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#006600; font-weight:bold;">&#40;</span>!session<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:pid</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#0000FF; font-weight:bold;">nil</span>? <span style="color:#9966CC; font-weight:bold;">and</span> session<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:pid</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_i</span> != 1<span style="color:#006600; font-weight:bold;">&#41;</span> ? <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">eval</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;client_#{match[1]}_#{match[2]}(arguments.first)&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> :<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">eval</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;#{match[1]}_#{match[2]}(arguments.first)&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <br />
<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#6666ff; font-weight:bold;">ActionView::Base</span>,<span style="color:#6666ff; font-weight:bold;">ActionController::Base</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">each</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> <br />
&nbsp; x.<span style="color:#9900CC;">send</span> :<span style="color:#9966CC; font-weight:bold;">include</span>, PathHelper <br />
<span style="color:#006600; font-weight:bold;">&#125;</span></div></td></tr></tbody></table></div>
<p>hope this helps anybody!</p>
<p>Any suggestions for a better solution w/o changing railscode?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.abelkilledcain.de/different-route-same-pathurl-calling-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>svn: Can&#8217;t convert string from &#8216;UTF-8&#8242; to native encoding</title>
		<link>http://www.abelkilledcain.de/svn-cant-convert-string-from-utf-8-to-native-encoding/</link>
		<comments>http://www.abelkilledcain.de/svn-cant-convert-string-from-utf-8-to-native-encoding/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 11:53:52 +0000</pubDate>
		<dc:creator>inbreed</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.abelkilledcain.de/?p=112</guid>
		<description><![CDATA[Today i was bored by svn. Filenames containing &#8220;special characters&#8221; can cause an annoying Subversion error message:
1svn: Can't convert string from 'UTF-8' to native encoding:
From the subversion book:
Errors like this typically occur when the Subversion client has received a UTF-8 string from the repository, but not all of the characters in that string can be [...]]]></description>
			<content:encoded><![CDATA[<p>Today i was bored by svn. Filenames containing &#8220;special characters&#8221; can cause an annoying Subversion error message:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">svn: Can't convert string from 'UTF-8' to native encoding:</div></td></tr></tbody></table></div>
<p>From the subversion book:</p>
<blockquote><p>Errors like this typically occur when the Subversion client has received a UTF-8 string from the repository, but not all of the characters in that string can be represented using the encoding of the current locale. For example, if your locale is en_US but a collaborator has committed a Japanese filename, you&#8217;re likely to see this error when you receive the file during an svn update.</p></blockquote>
<p>To fix this error message you have to set your current locale appropriately:<br />
<span id="more-112"></span></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Pussybook Pro:~ inbreed$ export LC_CTYPE=en_US.UTF-8<br />
Pussybook Pro:~ inbreed$ locale<br />
LANG=<br />
LC_COLLATE=&quot;C&quot;<br />
LC_CTYPE=&quot;en_US.UTF-8&quot;<br />
LC_MESSAGES=&quot;C&quot;<br />
LC_MONETARY=&quot;C&quot;<br />
LC_NUMERIC=&quot;C&quot;<br />
LC_TIME=&quot;C&quot;<br />
LC_ALL=&quot;C/en_US.UTF-8/C/C/C/C&quot;<br />
Pussybook Pro:~ inbreed$ svn update</div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.abelkilledcain.de/svn-cant-convert-string-from-utf-8-to-native-encoding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Noticed: getting yourself confused with helper methods!</title>
		<link>http://www.abelkilledcain.de/noticed-getting-yourself-confused-with-helper-methods/</link>
		<comments>http://www.abelkilledcain.de/noticed-getting-yourself-confused-with-helper-methods/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 22:40:40 +0000</pubDate>
		<dc:creator>inbreed</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.abelkilledcain.de/?p=108</guid>
		<description><![CDATA[Just a rather small hint for rails users.
Today i was getting angry about rails, since it told me that a specific method would not exist.. but i knew that i did exists, and both of us were wrong.
How come: i moved a method vom controller to helper, but forgott to remove it from helper_methods.
So Rails [...]]]></description>
			<content:encoded><![CDATA[<p>Just a rather small hint for rails users.</p>
<p>Today i was getting angry about rails, since it told me that a specific method would not exist.. but i knew that i did exists, and both of us were wrong.</p>
<p>How come: i moved a method vom controller to helper, but forgott to remove it from helper_methods.</p>
<p>So Rails claims, that the gived method does not exists. Strange, but true, it complains when you call it in code or template,  silence when you just add it as helper_method.</p>
<p>So be warned, be smarter than i was ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.abelkilledcain.de/noticed-getting-yourself-confused-with-helper-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
