<?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>Gudasoft &#187; rails</title>
	<atom:link href="http://www.gudasoft.com/tag/rails/feed" rel="self" type="application/rss+xml" />
	<link>http://www.gudasoft.com</link>
	<description>Impossible is nothing</description>
	<lastBuildDate>Thu, 06 Oct 2011 07:17:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>Getting fast with rspec</title>
		<link>http://www.gudasoft.com/english/development/11/29/1179/getting-fast-with-rspec/2009</link>
		<comments>http://www.gudasoft.com/english/development/11/29/1179/getting-fast-with-rspec/2009#comments</comments>
		<pubDate>Sun, 29 Nov 2009 18:03:00 +0000</pubDate>
		<dc:creator>guda</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.gudasoft.com/?p=1179</guid>
		<description><![CDATA[get the gem from here http://github.com/timcharper/spork &#160; How to fix the Missing error http://chrisblunt.com/blog/2009/08/28/rails-configuring-rspec-for-spork/ &#160;]]></description>
			<content:encoded><![CDATA[<p>get the gem from here</p>
<p>http://github.com/timcharper/spork</p>
<p>&nbsp;</p>
<p>How to fix the Missing error</p>
<p>http://chrisblunt.com/blog/2009/08/28/rails-configuring-rspec-for-spork/</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gudasoft.com/english/development/11/29/1179/getting-fast-with-rspec/2009/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Ubuntu workstation configuration</title>
		<link>http://www.gudasoft.com/english/linux/06/24/989/my-ubutno-workstation-configuration/2009</link>
		<comments>http://www.gudasoft.com/english/linux/06/24/989/my-ubutno-workstation-configuration/2009#comments</comments>
		<pubDate>Wed, 24 Jun 2009 18:42:39 +0000</pubDate>
		<dc:creator>guda</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[admini]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.gudasoft.com/?p=989</guid>
		<description><![CDATA[XOrg configuration https://wiki.ubuntu.com/X/Config/Resolution cvt 1680 1050 75 xrandr &#8211;newmode &#8230;the output from cvt xrandr &#8211;newmode &#8220;1680x1050_75.00&#8243; 187.00 1680 1800 1976 2272 1050 1053 1059 1099 -hsync +vsync xrandr &#8211;addmode DVI-0 1680x1050_75.00 Lenovo Y510 You have to install the latest alsa. Then replace the existing kernel modules with the just build one. Then run depmod -a [...]]]></description>
			<content:encoded><![CDATA[<h1>XOrg configuration</h1>
<ul>
<li>https://wiki.ubuntu.com/X/Config/Resolution</li>
<li>cvt 1680 1050 75</li>
<li> xrandr &#8211;newmode &#8230;the output from cvt<br />
xrandr &#8211;newmode  &#8220;1680x1050_75.00&#8243;  187.00  1680 1800 1976 2272  1050 1053 1059 1099 -hsync +vsync</li>
<li> xrandr &#8211;addmode  DVI-0 1680x1050_75.00</li>
</ul>
<h1>Lenovo Y510</h1>
<p>You have to install the latest alsa.</p>
<p>Then replace the existing kernel modules with the just build one. Then run depmod -a as point kilbasar here</p>
<p>http://ubuntuforums.org/showthread.php?t=687663&amp;page=2</p>
<pre dir="ltr">sudo su
cd /lib/modules/2.6.22-14-generic/ubuntu/media/snd-hda-intel/
mv snd-hda-intel.ko snd-hda-intel.ko.bak
ln -s /lib/modules/2.6.22-14-generic/kernel/sound/pci/hda/snd-hda-intel.ko /lib/modules/2.6.22-14-generic/ubuntu/media/snd-hda-intel/snd-hda-intel.ko
cd /usr/src/alsa/alsa-driver-1.0.16rc2/modules
cp * /lib/modules/2.6.22-14-generic/kernel/sound/
depmod -a</pre>
<h1>Logitech Revolution MX</h1>
<p>http://x4.6times7.org/dokuwiki/doku.php/devlog/blog/howto_logitech_mx_revolution_on_ubuntu</p>
<ul>
<li>The mouse wheel control
<ul>
<li>Download from here http://goron.de/~froese/revoco/ or <a href="http://www.gudasoft.com/wp-content/uploads/2009/06/revoco-0.5.tar.gz">revoco-0.5.tar</a></li>
</ul>
<ul>
<li>make</li>
<li>sudo ./revoco manual=6</li>
<li><tt>lets try to add it in ~/.xprofile next time<br />
</tt></li>
</ul>
</li>
</ul>
<ul>
<li>Here is my xorg.conf</li>
</ul>
<pre>Section "Monitor"
 Identifier "External DVI"
 # 1680x1050 74.89 Hz (CVT 1.76MA) hsync: 82.31 kHz; pclk: 187.00 MHz
 Modeline "1680x1050_75.00"  187.00  1680 1800 1976 2272  1050 1053 1059 1099 -hsync +vsync
 # 1680x1050 59.95 Hz (CVT 1.76MA) hsync: 65.29 kHz; pclk: 146.25 MHz
 Modeline "1680x1050_60.00"  146.25  1680 1784 1960 2240  1050 1053 1059 1089 -hsync +vsync
 # 1680x1050 69.88 Hz (CVT) hsync: 76.58 kHz; pclk: 174.00 MHz
 Modeline "1680x1050_70.00"  174.00  1680 1800 1976 2272  1050 1053 1059 1096 -hsync +vsync
 Option "PreferedMode"    "1280x1024_75.00"
EndSection

Section "Screen"
 Identifier    "Configured Screen Device"
 Device    "Configured Video Device"
 SubSection "Display"
 Depth    24
 Modes "1680x1050" "1024x768" "640x480"
 Virtual    2960 1050
 EndSubSection
EndSection

Section "Device"
 Identifier    "Configured Video Device"
 Option    "Monitor-DVI-0" "External DVI"
EndSection</pre>
<h1>My Development setup commands</h1>
<p>I noticed simillar post <a href="http://yobine.tistory.com/?page=3">here</a></p>
<pre>sudo aptitude install mc vim subversion screen pidgin meld curl links2 vim-ruby vim-gnome vim-doc vim-scripts vim-ruby vim-perl \
subversion git-core bluefish kompozer\
libmysqlclient15off libmysqlclient15-dev mysql-common mysql-client \
libmysql-ruby1.8 irb ruby1.8 rdoc ri rake \
apt-utils build-essential ruby1.8-dev mysql-server memcached libxslt1-dev libpcre3-dev zlib1g-dev unzip gzip mytop openssl \
libopenssl-ruby libmagick9-dev imagemagick librmagick-ruby1.8 imagemagick librmagick-ruby-doc  libmagick9-dev ruby1.8-dev \
libdbd-sqlite3-ruby libsqlite3-ruby sqlite3 libsqlite3-dev

ln -s /usr/bin/ruby1.8 /usr/bin/ruby

mkdir ruby_install
cd ruby_install
wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz
tar xzvf ruby*
cd rubygems-1.3.5
ruby setup.rb
cd ..
cd ..

ln -s /usr/bin/gem1.8 /usr/bin/gem

gem install rails mysql mongrel mongrel_cluster rails paperclip will_paginate andand \
json feed-normalizer hpricot mechanize ruby-debug uuid ruport ruport-util acts_as_reportable \
rufus-scheduler annotate openwferu-scheduler production_log_analyzer capistrano-ext libxml-ruby twitter capistrano wirble RedCloth
rspec-rails sqlite3-ruby \
--no-ri --no-rdoc

gem install rmagick -v 1.15.12
ruby -rrubygems -e "require 'RMagick'; puts Magick::Long_version;"

cat &gt; /home/guda/.irbrc
require 'rubygems'
require 'wirble'
Wirble.init
Wirble.colorize
require 'logger'
if ENV.include?('RAILS_ENV') &amp;&amp; !Object.const_defined?('RAILS_DEFAULT_LOGGER')
Object.const_set('RAILS_DEFAULT_LOGGER', Logger.new(STDOUT))
end

Gmail notification

http://www.workswithu.com/2009/10/06/gmail-notifier-applets-for-ubuntu/</pre>
<pre></pre>
<pre>What about <a href="http://ubuntu-tweak.com/">http://ubuntu-tweak.com/</a></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.gudasoft.com/english/linux/06/24/989/my-ubutno-workstation-configuration/2009/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some nice software that I am looking arround</title>
		<link>http://www.gudasoft.com/english/development/06/05/942/some-nice-software-that-i-am-looking-arround/2009</link>
		<comments>http://www.gudasoft.com/english/development/06/05/942/some-nice-software-that-i-am-looking-arround/2009#comments</comments>
		<pubDate>Fri, 05 Jun 2009 10:24:33 +0000</pubDate>
		<dc:creator>guda</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[spi]]></category>

		<guid isPermaLink="false">http://www.gudasoft.com/?p=942</guid>
		<description><![CDATA[libhttp-access2 &#8211; lwp for ruby ruby ide http://github.com/danlucraft/redcar/tree/master]]></description>
			<content:encoded><![CDATA[<p>libhttp-access2 &#8211; lwp for ruby</p>
<p>ruby ide http://github.com/danlucraft/redcar/tree/master</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gudasoft.com/english/development/06/05/942/some-nice-software-that-i-am-looking-arround/2009/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rake mysql tasks</title>
		<link>http://www.gudasoft.com/english/development/rails-development/05/06/880/rake-mysql-tasks/2009</link>
		<comments>http://www.gudasoft.com/english/development/rails-development/05/06/880/rake-mysql-tasks/2009#comments</comments>
		<pubDate>Wed, 06 May 2009 19:06:13 +0000</pubDate>
		<dc:creator>guda</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rake]]></category>

		<guid isPermaLink="false">http://www.gudasoft.com/?p=880</guid>
		<description><![CDATA[I have found that I should be quicker if I put the following task in all my small projects. require &#8216;find&#8217; namespace :mysql do desc &#8220;Perform mysql dump on the RAILS_ENV environment&#8221; task :dump =&#62; :environment do db_config = ActiveRecord::Base.configurations[RAILS_ENV] backup_file = &#8220;#{db_config['database']}.sql&#8221; cmd = &#8220;mysqldump -u #{db_config['username']} -p#{db_config['password']} -Q &#8211;add-drop-table -O add-locks=FALSE -O lock-tables=FALSE [...]]]></description>
			<content:encoded><![CDATA[<p>I have found that I should be quicker if I put the following task in all my small projects.<br />
<span id="more-880"></span></p>
<p>require &#8216;find&#8217;<br />
namespace :mysql do<br />
desc &#8220;Perform mysql dump on the RAILS_ENV environment&#8221;<br />
task :dump =&gt; :environment do<br />
db_config = ActiveRecord::Base.configurations[RAILS_ENV]<br />
backup_file = &#8220;#{db_config['database']}.sql&#8221;<br />
cmd = &#8220;mysqldump -u #{db_config['username']} -p#{db_config['password']} -Q &#8211;add-drop-table -O add-locks=FALSE -O lock-tables=FALSE #{db_config['database']} -r #{backup_file}&#8221;<br />
puts cmd<br />
sh cmd<br />
end</p>
<p>desc &#8220;imports the dumped database in the mysql FILE&#8221;<br />
task :import =&gt; :environment do |t, args|<br />
version = ENV["FILE"] ? ENV["FILE"].to_i : nil<br />
raise &#8220;FILE is required&#8221; unless version</p>
<p>db_config = ActiveRecord::Base.configurations[RAILS_ENV]<br />
backup_file = ENV["FILE"]<br />
sh &#8220;mysql -u #{db_config['username']} -p#{db_config['password']} -e \&#8221;CREATE DATABASE IF NOT EXISTS #{db_config['database']}\&#8221; &#8221;<br />
sh &#8220;mysql -u #{db_config['username']} -p#{db_config['password']} #{db_config['database']} &lt; #{backup_file}&#8221;<br />
end</p>
<p>desc &#8220;runs the mysql console for the selected RAILS_ENV&#8221;<br />
task :console =&gt; :environment do<br />
db_config = ActiveRecord::Base.configurations[RAILS_ENV]<br />
backup_file = &#8220;#{db_config['database']}.sql&#8221;<br />
cmd = &#8220;mysql -u #{db_config['username']} -p#{db_config['password']} #{db_config['database']}&#8221;<br />
sh cmd<br />
end</p>
<p>end</p>
<p>The task dumps just make a mysql dump from the current environment. Hmm. The next step is to transfer it with scp to my host.</p>
<p>Grab from <a href="http://errtheblog.com/posts/31-rake-around-the-rosie">here</a> the mysql console task</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gudasoft.com/english/development/rails-development/05/06/880/rake-mysql-tasks/2009/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Last thinks that I have read</title>
		<link>http://www.gudasoft.com/uncategorized/02/18/532/last-thinks-that-i-have-read/2009</link>
		<comments>http://www.gudasoft.com/uncategorized/02/18/532/last-thinks-that-i-have-read/2009#comments</comments>
		<pubDate>Wed, 18 Feb 2009 14:45:46 +0000</pubDate>
		<dc:creator>guda</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.gudasoft.com/uncategorized/02/18/532/last-thinks-that-i-have-read/2009</guid>
		<description><![CDATA[http://railsguts.com/ http://www.espace.com.eg/neverblock http://m.onkey.org/2008/11/17/ruby-on-rack-1 http://m.onkey.org/ http://www.gnome-db.org/Download http://loriholden.com/ http://www.bestechvideos.com/ Flex http://www.adobe.com/devnet/flex/articles/total_training_ch1.html# http://www.adobe.com/devnet/flex/learn/programmer/learningpath.html http://www.deitel.com/ResourceCenters/Programming/AdobeFlex/AdobeFlexVideos/tabid/1699/Default.aspx http://conference.startup-bg.org/2008/?page_id=696]]></description>
			<content:encoded><![CDATA[<p>http://railsguts.com/</p>
<p>http://www.espace.com.eg/neverblock</p>
<p>http://m.onkey.org/2008/11/17/ruby-on-rack-1</p>
<p>http://m.onkey.org/</p>
<p>http://www.gnome-db.org/Download</p>
<p>http://loriholden.com/</p>
<p>http://www.bestechvideos.com/</p>
<p>Flex</p>
<ul>
<li><a href="http://www.adobe.com/devnet/flex/articles/total_training_ch1.html#">http://www.adobe.com/devnet/flex/articles/total_training_ch1.html#</a></li>
<li><a href="http://www.adobe.com/devnet/flex/learn/programmer/learningpath.html">http://www.adobe.com/devnet/flex/learn/programmer/learningpath.html</a></li>
<li><a href="http://www.deitel.com/ResourceCenters/Programming/AdobeFlex/AdobeFlexVideos/tabid/1699/Default.aspx">http://www.deitel.com/ResourceCenters/Programming/AdobeFlex/AdobeFlexVideos/tabid/1699/Default.aspx</a></li>
</ul>
<p><a href="http://conference.startup-bg.org/2008/?page_id=696">http://conference.startup-bg.org/2008/?page_id=696</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gudasoft.com/uncategorized/02/18/532/last-thinks-that-i-have-read/2009/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Merging search criteria with merge_conditions</title>
		<link>http://www.gudasoft.com/uncategorized/02/18/528/merging-search-criteria-with-merge_conditions/2009</link>
		<comments>http://www.gudasoft.com/uncategorized/02/18/528/merging-search-criteria-with-merge_conditions/2009#comments</comments>
		<pubDate>Wed, 18 Feb 2009 13:40:16 +0000</pubDate>
		<dc:creator>guda</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.gudasoft.com/uncategorized/02/18/528/merging-search-criteria-with-merge_conditions/2009</guid>
		<description><![CDATA[def search(params = {}) cond = [] cond &#60;&#60; ["name LIKE ?", params[:name] + '%'] unless params[:name].blank? cond &#60;&#60; ["email = ?", params[:email]] unless params[:email].blank? conditions = cond.map { &#124;c&#124; User.merge_conditions(c) }.join(' AND ') User.find(:all, :conditions =&#62; conditions) end]]></description>
			<content:encoded><![CDATA[<div class="wp_syntax">
<div class="code">
<pre class="ruby">  <span style="color: #9966cc; font-weight: bold;">def</span> search<span style="color: #006600; font-weight: bold;">(</span>params = <span style="color: #006600; font-weight: bold;">{</span><span style="color: #006600; font-weight: bold;">}</span><span style="color: #006600; font-weight: bold;">)</span>
    cond = <span style="color: #006600; font-weight: bold;">[</span><span style="color: #006600; font-weight: bold;">]</span>
    cond <span style="color: #006600; font-weight: bold;">&lt;&lt;</span> <span style="color: #006600; font-weight: bold;">[</span><span style="color: #996600;">"name LIKE ?"</span>, params<span style="color: #006600; font-weight: bold;">[</span><span style="color: #ff3333; font-weight: bold;">:name</span><span style="color: #006600; font-weight: bold;">]</span> <span style="color: #006600; font-weight: bold;">+</span> <span style="color: #996600;">'%'</span><span style="color: #006600; font-weight: bold;">]</span> <span style="color: #9966cc; font-weight: bold;">unless</span> params<span style="color: #006600; font-weight: bold;">[</span><span style="color: #ff3333; font-weight: bold;">:name</span><span style="color: #006600; font-weight: bold;">]</span>.<span style="color: #9900cc;">blank</span>?
    cond <span style="color: #006600; font-weight: bold;">&lt;&lt;</span> <span style="color: #006600; font-weight: bold;">[</span><span style="color: #996600;">"email = ?"</span>,   params<span style="color: #006600; font-weight: bold;">[</span><span style="color: #ff3333; font-weight: bold;">:email</span><span style="color: #006600; font-weight: bold;">]</span><span style="color: #006600; font-weight: bold;">]</span>       <span style="color: #9966cc; font-weight: bold;">unless</span> params<span style="color: #006600; font-weight: bold;">[</span><span style="color: #ff3333; font-weight: bold;">:email</span><span style="color: #006600; font-weight: bold;">]</span>.<span style="color: #9900cc;">blank</span>?
    conditions = cond.<span style="color: #9900cc;">map</span> <span style="color: #006600; font-weight: bold;">{</span> <span style="color: #006600; font-weight: bold;">|</span>c<span style="color: #006600; font-weight: bold;">|</span> User.merge_conditions<span style="color: #006600; font-weight: bold;">(</span>c<span style="color: #006600; font-weight: bold;">)</span> <span style="color: #006600; font-weight: bold;">}</span>.<span style="color: #9900cc;">join</span><span style="color: #006600; font-weight: bold;">(</span><span style="color: #996600;">' AND '</span><span style="color: #006600; font-weight: bold;">)</span>
    User.find<span style="color: #006600; font-weight: bold;">(</span><span style="color: #ff3333; font-weight: bold;">:all</span>, <span style="color: #ff3333; font-weight: bold;">:conditions</span> <span style="color: #006600; font-weight: bold;">=&gt;</span> conditions<span style="color: #006600; font-weight: bold;">)</span>
  <span style="color: #9966cc; font-weight: bold;">end</span>
<span style="color: #9966cc; font-weight: bold;">
</span></pre>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.gudasoft.com/uncategorized/02/18/528/merging-search-criteria-with-merge_conditions/2009/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Installing notes for Rails on Debian/Ubunto</title>
		<link>http://www.gudasoft.com/english/development/rails-development/11/06/246/installing-notes-for-rails-on-debianubunto/2008</link>
		<comments>http://www.gudasoft.com/english/development/rails-development/11/06/246/installing-notes-for-rails-on-debianubunto/2008#comments</comments>
		<pubDate>Thu, 06 Nov 2008 20:17:13 +0000</pubDate>
		<dc:creator>guda</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.gudasoft.com/?p=246</guid>
		<description><![CDATA[Debian Etch with backports Add this line in sources.list to get rails &#62; 1.8.5 in rails etch deb http://www.backports.org/debian etch-backports main contrib non-free # deb ftp://ftp.nz.debian.org/backports etch-backports main contrib non-free apt-get install debian-backports-keyring aptitude update # some ruby stuff aptitude install -t etch-backports ruby1.8-dev libmysqlclient15off libmysqlclient15-dev mysql-common mysql-client libmysql-ruby1.8 # some system utils/libs aptitude install [...]]]></description>
			<content:encoded><![CDATA[<p>Debian Etch with backports</p>
<p>Add this line in sources.list to get rails &gt; 1.8.5 in rails etch</p>
<pre><code>deb http://www.backports.org/debian etch-backports main contrib non-free
# deb ftp://ftp.nz.debian.org/backports etch-backports main contrib non-free
apt-get install debian-backports-keyring
aptitude update

# some ruby stuff
aptitude install -t etch-backports ruby1.8-dev libmysqlclient15off libmysqlclient15-dev mysql-common mysql-client libmysql-ruby1.8

# some system utils/libs
aptitude install apt-utils build-essential mysql-server mysql-common mysql-client memcached libxslt1-dev libpcre3-dev zlib1g-dev unzip gzip mytop  openssl

aptitude install -t etch-backports libopenssl-ruby

# gems
gem install rails mongrel mongrel_cluster -y
</code></pre>
<p>check this <a href="http://kete.net.nz/documentation/topics/show/116">step-by-step</a></p>
<p>Image magick linux howto &#8211; http://rmagick.rubyforge.org/install2-linux.html</p>
<pre><code>aptitude install libmagick9-dev  imagemagick librmagick-ruby1.8 imagemagick librmagick-ruby-doc  libmagick9-dev ruby1.8-dev</code></pre>
<pre><code>

# for version 1 of imagemagick we use this rmagick, else try it without the -v
gem install rmagick -v 1.15.12 

# lets test it
&gt; irb
require 'rubygems'
require 'RMagick'
Magick::CenterGravity
puts Magick::Long_version

# or with 

ruby -rrubygems -e "require 'RMagick'; puts Magick::Long_version;" 

</code></pre>
<p>I love this tutorial on <a href="http://www.rubyinside.com/how-to-install-a-ruby-18-stack-on-ubuntu-810-from-scratch-1566.html">rubyinside</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gudasoft.com/english/development/rails-development/11/06/246/installing-notes-for-rails-on-debianubunto/2008/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>syslog-ng and rails</title>
		<link>http://www.gudasoft.com/uncategorized/09/05/116/syslog-ng-and-rails/2008</link>
		<comments>http://www.gudasoft.com/uncategorized/09/05/116/syslog-ng-and-rails/2008#comments</comments>
		<pubDate>Fri, 05 Sep 2008 11:13:10 +0000</pubDate>
		<dc:creator>guda</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.gudasoft.com/?p=116</guid>
		<description><![CDATA[My Syslog-ng.conf file The interesting part is the final flag which tells the syslog not to process any further the message. This way the message stays only in the rails application logfile. log { source(src); filter(f_rails); destination(rails_log); flags(final); }; Here is the whole conf file options { chain_hostnames(off); sync(0);dns_cache(2000); dns_cache_expire(87600); # The default action of [...]]]></description>
			<content:encoded><![CDATA[<h1>My Syslog-ng.conf file</h1>
<p>The interesting part is the final flag which tells the syslog not to process any further the message. This way the message stays only in the rails application logfile.</p>
<p><code>log { source(src); filter(f_rails); destination(rails_log); flags(final); };</code></p>
<p>Here is the whole conf file</p>
<p><span id="more-116"></span><br />
<code><br />
options {<br />
chain_hostnames(off);<br />
sync(0);dns_cache(2000);<br />
dns_cache_expire(87600);<br />
# The default action of syslog-ng 1.6.0 is to log a STATS line<br />
# to the file every 10 minutes.  That's pretty ugly after a while.<br />
# Change it to every 12 hours so you get a nice daily update of<br />
# how many messages syslog-ng missed (0).<br />
stats(43200);<br />
};</code></p>
<p>destination messages { file(&#8220;/var/log/messages&#8221;); };</p>
<p># By default messages are logged to tty12&#8230;<br />
# destination console_all { file(&#8220;/dev/tty12&#8243;); };<br />
# &#8230;if you intend to use /dev/console for programs like xconsole<br />
# you can comment out the destination line above that references /dev/tty12<br />
# and uncomment the line below.<br />
#destination console_all { file(&#8220;/dev/console&#8221;); };</p>
<p>source src {<br />
unix-stream(&#8220;/dev/log&#8221; max-connections(256));<br />
internal();<br />
file(&#8220;/proc/kmsg&#8221;);<br />
};</p>
<p>destination rails_log { file(&#8220;/var/log/system3.log&#8221;); };<br />
filter f_rails { program(&#8220;rails.*&#8221;); };<br />
log { source(src); filter(f_rails); destination(rails_log); flags(final); };</p>
<p>log { source(src); destination(messages); };<br />
log { source(src); destination(console_all); };</p>
<p>On my last Debian Etch installation I have to commeted the &#8220;source src&#8221; and added just those lines</p>
<p># we will use the default source configuration</p>
<p>#source src {<br />
#unix-stream(&#8220;/dev/log&#8221; max-connections(256));<br />
#internal();<br />
#file(&#8220;/proc/kmsg&#8221;);<br />
#};</p>
<p>destination rails_log { file(&#8220;/var/log/system3.log&#8221;); };<br />
filter f_rails { program(&#8220;rails.*&#8221;); };<br />
log { source(s_all); filter(f_rails); destination(rails_log); flags(final); };</p>
<p>Put this at the beginig of the log {} directives because we need want the final flag to take affect.</p>
<p>http://www.blueboxgrp.com/news/2009/06/unified_rails_logging_with_syslog-ng</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gudasoft.com/uncategorized/09/05/116/syslog-ng-and-rails/2008/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails caching notes</title>
		<link>http://www.gudasoft.com/english/development/rails-development/08/26/111/rails-caching/2008</link>
		<comments>http://www.gudasoft.com/english/development/rails-development/08/26/111/rails-caching/2008#comments</comments>
		<pubDate>Tue, 26 Aug 2008 19:31:02 +0000</pubDate>
		<dc:creator>guda</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.gudasoft.com/?p=111</guid>
		<description><![CDATA[General Notes Very nice tutorial for rails 2.1 caching. API references: Fragments, Sweepers, the Store Post how to move the page cache in a folder with some server examples Observing Controllers with Sweepers Here is described how you can use the Sweepers to observe controller actions. I totaly agree that the documenation is very bad [...]]]></description>
			<content:encoded><![CDATA[<h2>General Notes</h2>
<p>Very nice <a href="http://www.ibm.com/developerworks/web/library/wa-rails1/">tutorial</a> for rails 2.1 caching.</p>
<p>API references: <a href="http://api.rubyonrails.org/classes/ActionController/Caching/Fragments.html#M000641">Fragments,</a> <a href="http://api.rubyonrails.org/classes/ActionController/Caching/Sweeping.html">Sweepers,</a> the <a href="http://api.rubyonrails.org/classes/ActiveSupport/Cache/MemoryStore.html">Store</a></p>
<p><a href="http://www.fngtps.com/2006/01/lazy-sweeping-the-rails-page-cache">Post</a> how to move the page cache in a folder with some server examples</p>
<h2>Observing Controllers with Sweepers</h2>
<p><a href="http://codelevy.com/articles/2008/03/04/rails-caching-sweepers-controllers-and-models">Here</a> is described how you can use the <a href="http://api.rubyonrails.org/classes/ActionController/Caching/Sweeping.html">Sweepers</a> to observe controller actions. I totaly agree that the documenation is very bad on the sweepers and it is like a rule book of <a href="http://www.wizards.com/magic/">MTG</a> than usefull rdoc.</p>
<p>Here is what I have found on the naming of the callbacks.</p>
<p>Checking the source code in <a href="file:///var/lib/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/caching/sweeping.rb">sweeping.rb</a> shows that the callbacks that are used for the controller are constructed in this way:<br />
<code><br />
controller_callback_method_name = "#{timing}_#{controller.controller_name.underscore}"<br />
action_callback_method_name     = "#{controller_callback_method_name}_#{controller.action_name}"</code></p>
<p>This means that the method which will be called in the sweeper will be named</p>
<ul>
<li>after/before_user &#8211; for the controller UserController</li>
<li>after/before_user_login &#8211; for the action login in the controller UserController</li>
</ul>
<p>Here is an example.</p>
<pre>class Dagens::UserController &lt; Dagens::BaseController
  cache_sweeper DagensAgentSweeper, :only =&gt; [:do_login, :do_delete_account, :do_logout]
  def do_login
  end
  ....
end

class DagensAgentSweeper &lt; ActionController::Caching::Sweeper
  observe DagensAgent

  def after_user_do_login
    puts "after do login \n \n \n \n \n \n \n "
    expire_cache_for(@logged_user)
  end
end</pre>
<h2>Skipping callbacks from an observer</h2>
<p>I know that it is not good idea, but some times there is no time/way to do skip it. I have found a plugin and this post <a href="http://integrumbles.com/2007/12/12/skipping-activerecord-callback-methods">here</a>. I have choose to use the second one in my project. Here is the example</p>
<pre>class DagensAgentSweeper &lt; ActionController::Caching::Sweeper
  observe DagensAgent

  def self.skip_callback(callback, &amp;block)
    method = instance_method(callback)
    remove_method(callback) if respond_to?(callback)
    define_method(callback) { true }
    result = yield
    remove_method(callback)
    define_method(callback, method)
    result
  end
........
end</pre>
<p>And later in the controller&#8230;.model&#8230;</p>
<pre>      DagensAgentSweeper.skip_callback(:after_update) do
        @agent.shown_times += 1
        @agent.save
      end
</pre>
<h2>timed_fragment_cache</h2>
<p>Some patches on the <a href="http://www.ruzee.com/blog/2008/07/timed_fragment_cache-on-rails-21/ ">timed_fragment_cache</a> plugin.</p>
<p>Note how  Jolyon Says suggest to expire the cache when you have time zone :  <code>when_fragment_expired ‘tags_home_page’, Time.now + 10.minutes do</code></p>
<p>I have notice that timed_fragment_cache (or the patch) have a problem with expiring the cache from the controller. In the documenation it is stated that it is ok to expire the cache only in the controller with</p>
<p><code>when_fragment_expired  "_last_update",  Time.now + 1.minutes  do</code></p>
<p>and there is no need to expire it in the view, but you MUST expire it in the view.</p>
<p><code>cache "_last_update" do</code></p>
<p>must be</p>
<p><code>cache "_last_update", Time.now + 1.minutes  do</code></p>
<pre></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.gudasoft.com/english/development/rails-development/08/26/111/rails-caching/2008/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nginx with Rails</title>
		<link>http://www.gudasoft.com/english/linux/administration-linux/08/19/104/nginx-with-rails/2008</link>
		<comments>http://www.gudasoft.com/english/linux/administration-linux/08/19/104/nginx-with-rails/2008#comments</comments>
		<pubDate>Tue, 19 Aug 2008 15:37:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.gudasoft.com/?p=104</guid>
		<description><![CDATA[downloaded from here documentation here If you want to try different solution check it haproxy compiled with: ./configure --sbin-path=/usr/local/sbin --with-http_ssl_module --user=mongrel make make install with fair balancing Fair load balancing for nginx from here ./configure --with-http_ssl_module --user=mongre --add-module=/usr/local/src/gnosek-nginx-upstream-fair --prefix=/usr/local/nginx --error-log-path=/var/log --http-log-path=/var/log make &#38;&#38; make install base configuration from here more and my favorite here is [...]]]></description>
			<content:encoded><![CDATA[<p>downloaded from <a href="http://sysoev.ru/nginx/download.html">here</a><br />
documentation <a href="http://sysoev.ru/nginx/docs/">here</a><br />
If you want to try different solution check it <a href="http://affectioncode.wordpress.com/2008/06/28/another-comparison-of-haproxy-and-nginx/">haproxy</a> <span id="more-104"></span> <code> compiled with:  ./configure --sbin-path=/usr/local/sbin --with-http_ssl_module --user=mongrel make make install </code></p>
<h2>with fair balancing</h2>
<p>Fair load balancing for nginx from <a href="http://wiki.codemongers.com/NginxHttpUpstreamFairModule">here </a></p>
<p><code></p>
<pre>./configure  --with-http_ssl_module --user=mongre --add-module=/usr/local/src/gnosek-nginx-upstream-fair --prefix=/usr/local/nginx --error-log-path=/var/log --http-log-path=/var/log 

make &amp;&amp; make install</pre>
<p></code></p>
<p>base configuration from <a href="http://blog.kovyrin.net/files/nginx-conf/rproxy.nginx.conf">here</a><br />
<a href="http://brainspl.at/articles/2006/08/23/nginx-my-new-favorite-front-end-for-mongrel-cluster">more</a> and my <a href="http://blog.jordanisip.com/2007/6/27/rimuhosting-vps-nginx-mongrel-clusters-multiple-domains-a-happy-jordan">favorite</a> here is good <a href="https://calomel.org/nginx.html">overview of example config </a><br />
init script from <a href="http://blog.labratz.net/articles/2006/10/03/rails-deployment-apache-lighttpd-nginx-mongrel-cluster">here</a></p>
<p>http://haproxy.1wt.eu/ is alternative for the nginx</p>
<p>I have one mongrel cluster which is serving multiple rails applications. In my example I host http://system3.spider.bg and http://www.psspy.se in one mongrel cluster.  here are the conf files:</p>
<pre># cat nginx.conf
user  mongrel mongrel;
worker_processes  2;

#error_log  logs/error.log;
error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {
    #worker_connections  16385;
    worker_connections  1024;
}

http {
    default_type  application/octet-stream;
    include       mime.types;

    log_format  main  '$remote_addr - $remote_user [$time_local] $request '
                      '"$status" $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  logs/access.log  main;
    server_tokens off;

    sendfile        on;
    tcp_nopush     on;
    tcp_nodelay    on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip  on;
    gzip_proxied any;
#    gzip_http_version 1.1;
#    gzip_comp_level 1;
    gzip_types      text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    upstream truckhandboken_proxy {
        server 127.0.0.1:8000;
        server 127.0.0.1:8001;
    }

    upstream system3_proxy {
        server 127.0.0.1:8200;
        server 127.0.0.1:8201;
        server 127.0.0.1:8202;
        server 127.0.0.1:8203;
        server 127.0.0.1:8204;
        server 127.0.0.1:8205;
        server 127.0.0.1:8206;
        server 127.0.0.1:8207;
        server 127.0.0.1:8208;
        server 127.0.0.1:8209;
    }

    include     vhosts/*.conf;

    server {
        listen       80;
        server_name  localhost:80;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
}</pre>
<p>The virtual host file</p>
<pre># cat system3.conf
    server {
        listen       80;
        #listen      192.168.1.1;
        #listen      192.168.1.1:8080;

        server_name  system3.spider.bg www.system3.spider.bg;

        access_log  logs/system3.access.log  main;

        location / {
            proxy_pass         http://system3_proxy;
            proxy_redirect     off;

            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

            client_max_body_size       10m;
            client_body_buffer_size    128k;

            proxy_connect_timeout      90;
            proxy_send_timeout         90;
            proxy_read_timeout         90;

            proxy_buffer_size          4k;
            proxy_buffers              4 32k;
            proxy_busy_buffers_size    64k;
            proxy_temp_file_write_size 64k;
        }
    }

server {
        listen       80;
        #listen      192.168.1.1;
        #listen      192.168.1.1:8080;

        server_name  *.psspy.se psspy.se;
        root    /home/mongrel/system3/current/public;
        access_log  logs/psspy_access.log  main;

        # Set the max size for file uploads to 50Mb
        client_max_body_size 50M;

        # this rewrites all the requests to the maintenance.html
        # page if it exists in the doc root. This is for capistrano's
        # disable web task
        if (-f $document_root/system/maintenance.html) {
            rewrite  ^(.*)$  /system/maintenance.html last;
            break;
        }

        location = / {
            if (-f /index.html){
             rewrite (.*) /index.html last;
            }
            proxy_pass  http://system3_proxy/dagensps;

            proxy_redirect     off;

            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        }

        location / {
            proxy_redirect     off;

            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

            client_max_body_size       10m;
            client_body_buffer_size    128k;

            proxy_connect_timeout      90;
            proxy_send_timeout         90;
            proxy_read_timeout         90;

            proxy_buffer_size          4k;
            proxy_buffers              4 32k;
            proxy_busy_buffers_size    64k;
            proxy_temp_file_write_size 64k;

            # If the file exists as a static file serve it directly without
            # running all the other rewite tests on it
            if (-f $request_filename) {
                break;
            }

            # check for index.html for directory index
            # if its there on the filesystem then rewite
            # the url to add /index.html to the end of it
            # and then break to send it to the next config rules.
            if (-f $request_filename/index.html) {
                rewrite (.*) $1/index.html break;
            }

            # this is the meat of the rails page caching config
            # it adds .html to the end of the url and then checks
            # the filesystem for that file. If it exists, then we
            # rewite the url to have explicit .html on the end
            # and then send it on its way to the next config rule.
            # if there is no file on the fs then it sets all the
            # necessary headers and proxies to our upstream mongrels
            if (-f $request_filename.html) {
               rewrite (.*) $1.html break;
            }

            if (!-f $request_filename) {
              proxy_pass         http://system3_proxy;
              break;
            }
        } # location

    error_page   500 502 503 504  /500.html;
    location = /500.html {
      root   /home/mongrel/system3/current/public/500.html;
    }

    error_page   404  /404.html;
    location = /404.html {
      root   /home/mongrel/system3/current/public/404.html;
    }

}# server

Good text: http://rubypond.com/articles/2008/02/01/setting-up-nginx-ssl-and-virtual-hosts/
There is generartor gem <a href="http://errtheblog.com/posts/52-nginx-config-like-whoa"><span class="code">nginx_config_generator</span></a>
example scripts: http://topfunky.net/svn/shovel/nginx/

nginx connects <a href="http://www.igvita.com/2008/02/11/nginx-and-memcached-a-400-boost/">directly </a>to memcached for caching
for restarting nice you might want to see seesaw gem (presentation <a href="http://www.slideshare.net/addame/montreal-on-rails-5-rails-deployment-193082">here</a>) or this <a href="http://blog.carlmercier.com/2007/09/07/a-better-approach-to-restarting-a-mongrel-cluster/">blog</a></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.gudasoft.com/english/linux/administration-linux/08/19/104/nginx-with-rails/2008/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Do you need to change a filename before sending it ?</title>
		<link>http://www.gudasoft.com/english/development/rails-development/07/17/91/do-you-need-to-change-a-filename-before-sending-it/2008</link>
		<comments>http://www.gudasoft.com/english/development/rails-development/07/17/91/do-you-need-to-change-a-filename-before-sending-it/2008#comments</comments>
		<pubDate>Thu, 17 Jul 2008 13:39:16 +0000</pubDate>
		<dc:creator>guda</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.gudasoft.com/?p=91</guid>
		<description><![CDATA[Rails action to send binary data I have one old application where the attachment is store as an id in the filesystem. The customer wants to have the attachment with the right name. So I have made this small action which accepts the id of the requested object and send the file data. def send_bios [...]]]></description>
			<content:encoded><![CDATA[<h1>Rails action to send binary data</h1>
<p>I have one old application where the attachment is store as an id in the filesystem. The customer wants to have the attachment with the right name. So I have made this small action which accepts the id of the requested object and send the file data.</p>
<pre><code>
  def send_bios
    redirect_to :action =&gt; 'bios' if params[:id].blank?
    @artist = Artist.find(params[:id]);
    contents = File.open(@artist.bios_path,"rb") {|io| io.read}
    send_data contents, :filename =&gt; "#{@artist.name}.pdf", :type =&gt; "application/pdf", :disposition =&gt; 'attachment'
  end
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.gudasoft.com/english/development/rails-development/07/17/91/do-you-need-to-change-a-filename-before-sending-it/2008/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random images helper for Rails</title>
		<link>http://www.gudasoft.com/english/development/rails-development/07/01/80/random-images-helper-for-rails/2008</link>
		<comments>http://www.gudasoft.com/english/development/rails-development/07/01/80/random-images-helper-for-rails/2008#comments</comments>
		<pubDate>Tue, 01 Jul 2008 14:11:48 +0000</pubDate>
		<dc:creator>guda</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.gudasoft.com/?p=80</guid>
		<description><![CDATA[Here is how to make random images generation for your website. First you must put your images in a folder /public/images/random_images or what ever. Second you put images there and mark the filenames with a prefix, which image to which section will be visible on. index_bottom_1.jpg -&#62; for the index page on the bottom :) [...]]]></description>
			<content:encoded><![CDATA[<p>Here is how to make random images generation for your website.</p>
<p>First you must put your images in a folder /public/images/random_images or what ever.</p>
<p>Second you put images there and mark the filenames with a prefix, which image to which section will be visible on.</p>
<p>index_bottom_1.jpg -&gt; for the index page on the bottom :)</p>
<p>index_bottom_2.jpg -&gt; for the index page on the bottom</p>
<p>featured_art_1.jpg -&gt; some panel.</p>
<p>featured_art_2.jpg -&gt; some panel.</p>
<p>and so on&#8230;</p>
<p>Paste this method in your base controller. This method will be called to make list for a specific image folder and &#8220;filter&#8221; the images that are supposed to be showed in the different regions in @variables.</p>
<p><code> </code></p>
<pre>  before_filter :init_random_images
  protected # :) be carefull for this if you copy paste
  def init_random_images
    # collect some static images
    web_root = "images/imagestorage/random_images"

    all_images = Dir["#{RAILS_ROOT}/public/#{web_root}/*.jpg"]

    @random_head_images = []
    @random_indexbtm = []
    @random_featured = []
    @random_sales = []
    @random_services = []
    @random_framing = []
    @random_artistcollection = []
    all_images.each do |f|
      if File.stat(f).file?
        @random_head_images &lt;&lt; ("/#{web_root}/" + File.basename(f)) if f =~ /head_images_/
        @random_indexbtm &lt;&lt; ("/#{web_root}/" + File.basename(f)) if f =~ /indexbtm_/
        @random_featured &lt;&lt; ("/#{web_root}/" + File.basename(f)) if f =~ /featured_/
        @random_sales &lt;&lt; ("/#{web_root}/" + File.basename(f)) if f =~ /sales_/
        @random_services &lt;&lt; ("/#{web_root}/" + File.basename(f)) if f =~ /services_/
        @random_framing &lt;&lt; ("/#{web_root}/" + File.basename(f)) if f =~ /framing_/
        @random_artistcollection &lt;&lt; ("/#{web_root}/" + File.basename(f)) if f =~ /artistcollection_/
      end
    end</pre>
<p>Then paste this as a helper or in the base controller, to use it in your views. The method will give you from the <code>images</code> array, <code>count</code> number of images.</p>
<p><code> </code></p>
<pre>  helper_method :get_random_image
  def get_random_image(images, count)
    requested_images = []
    images_copy = images.clone
    [images_copy.size, count].min.times do
      index = rand(images_copy.size)
      requested_images &lt;&lt; images_copy[index]
      images_copy.delete_at(index)
    end
    requested_images.flatten.compact
  end</pre>
<p>here is an example how to use it.</p>
<pre><code>&lt;div id="static_logo" style="background:url(&lt;%= get_random_image(@random_sales, 1) %&gt;) no-repeat scroll left top;"&gt;
 </code></pre>
<h1>Future optimization</h1>
<p>Put some caching, not to make</p>
<pre><code>Dir["#{RAILS_ROOT}/public/#{web_root}/*.jpg"]
 </code></pre>
<p>on every request.</p>
<p>10x Bl8cki to the nice code optimizations :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gudasoft.com/english/development/rails-development/07/01/80/random-images-helper-for-rails/2008/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rails conf 2008/6/2</title>
		<link>http://www.gudasoft.com/uncategorized/06/16/74/rails-conf-200862/2008</link>
		<comments>http://www.gudasoft.com/uncategorized/06/16/74/rails-conf-200862/2008#comments</comments>
		<pubDate>Mon, 16 Jun 2008 17:26:58 +0000</pubDate>
		<dc:creator>guda</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.gudasoft.com/?p=74</guid>
		<description><![CDATA[Its aways nice to know whats going on in rails field http://railsenvy.com/2008/6/2/Railsconf-videos Whats new for me was flog: http://on-ruby.blogspot.com/2007/12/flog-profiling-complexity.html http://ruby.sadi.st/Flog.html Some more video links]]></description>
			<content:encoded><![CDATA[<p>Its aways nice to know whats going on in rails field</p>
<p>http://railsenvy.com/2008/6/2/Railsconf-videos</p>
<p>Whats new for me was flog:</p>
<ul>
<li>http://on-ruby.blogspot.com/2007/12/flog-profiling-complexity.html</li>
<li>http://ruby.sadi.st/Flog.html</li>
</ul>
<p>Some more video <a href="http://www.vimeo.com/1104776">links</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gudasoft.com/uncategorized/06/16/74/rails-conf-200862/2008/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Only get, head, post, put, and delete requests are allowed.</title>
		<link>http://www.gudasoft.com/english/development/rails-development/06/13/71/only-get-head-post-put-and-delete-requests-are-allowed/2008</link>
		<comments>http://www.gudasoft.com/english/development/rails-development/06/13/71/only-get-head-post-put-and-delete-requests-are-allowed/2008#comments</comments>
		<pubDate>Fri, 13 Jun 2008 09:35:59 +0000</pubDate>
		<dc:creator>guda</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.gudasoft.com/?p=71</guid>
		<description><![CDATA[I got this error when I have to upgrade one old project from rails 1.2.5 to rails 2.1 (the problem is not in rails) ActionController::MethodNotAllowed Only get, head, post, put, and delete requests are allowed. The exception: ActionController::MethodNotAllowed (Only get, head, post, put, and delete requests are allowed.): /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/routing/recognition_optimisation.rb:65:in `recognize_path' /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/routing/route_set.rb:384:in `recognize' I got this [...]]]></description>
			<content:encoded><![CDATA[<p>I got this error when I have to upgrade one old project from rails 1.2.5 to rails 2.1 (the problem is not in rails)</p>
<pre>ActionController::MethodNotAllowed

Only get, head, post, put, and delete requests are allowed.</pre>
<p>The exception:</p>
<pre>ActionController::MethodNotAllowed (Only get, head, post, put, and delete requests are allowed.):
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/routing/recognition_optimisation.rb:65:in `recognize_path'
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/routing/route_set.rb:384:in `recognize'</pre>
<p>I got this error only when I access URL&#8217;s with param like</p>
<p>http://127.0.0.1:3000/dod/images/show_big_image/1639</p>
<p>I found that the problem was in the :id because without the :id the method was called correctly</p>
<p>This means that there is something with the routes.</p>
<p>Not working routes.rb: &#8230;.<br />
<code> </code></p>
<pre>  map.connect '', :controller =&gt; 'auth'

  # Install the default route as the lowest priority.
  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:sort_key/:sort_order'</pre>
<p>it will work if you swap the last two lines&#8230;.</p>
<p><code> </code></p>
<pre>  map.connect '', :controller =&gt; 'auth'

  # Install the default route as the lowest priority.
  map.connect ':controller/:action/:sort_key/:sort_order'
  map.connect ':controller/:action/:id'</pre>
<p>It seems that it does reading the comments in the routes.rb is usefull. There is written:<br />
<code> </code></p>
<pre><strong># Install the default route as the lowest priority.

</strong>This error also occurs if you haven't restart your webserver. I know that there is no need to restart it but its true, try restarting and check.</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.gudasoft.com/english/development/rails-development/06/13/71/only-get-head-post-put-and-delete-requests-are-allowed/2008/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rails plugins, gems, search engines, applications</title>
		<link>http://www.gudasoft.com/uncategorized/05/26/28/rails-plugins/2008</link>
		<comments>http://www.gudasoft.com/uncategorized/05/26/28/rails-plugins/2008#comments</comments>
		<pubDate>Mon, 26 May 2008 06:18:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://blog.gudasoft.com/?p=28</guid>
		<description><![CDATA[Plugins &#38; gems lists Associations http://www.workingwithrails.com/railsplugin/4801-has-many-polymorphs Versioning of AR http://github.com/fatjam/acts_as_revisable/tree/master http://opensoul.org/2006/7/21/acts_as_audited Scafolding http://streamlinedframework.org/pages/about Ajax pagination with JQuery http://ozmm.org/posts/ajax_will_paginate_jq_style.html Find_by_param is a nice and easy way to handle permalinks and dealing with searching for to_param values http://github.com/bumi/find_by_param/tree/master Asset Plugin &#8211; better than rails 2.0 integrated http://synthesis.sbecker.net/pages/asset_packager Image Magic http://vantulder.net/rails/magick/ OpenID http://wiki.rubyonrails.org/rails/pages/OpenidLoginGenerator http://github.com/technoweenie/restful-authentication/tree/master http://github.com/mrflip/ Model graph visualize [...]]]></description>
			<content:encoded><![CDATA[<h2>Plugins &amp; gems lists</h2>
<p>Associations</p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">http://www.workingwithrails.com/railsplugin/4801-has-many-polymorphs</p>
<p>Versioning of AR</p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">http://github.com/fatjam/acts_as_revisable/tree/master</p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">http://opensoul.org/2006/7/21/acts_as_audited</p>
<p>Scafolding</p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">http://streamlinedframework.org/pages/about</p>
<p>Ajax pagination with JQuery</p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">http://ozmm.org/posts/ajax_will_paginate_jq_style.html</p>
<p>Find_by_param is a nice and easy way to handle permalinks and dealing with searching for to_param values</p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">http://github.com/bumi/find_by_param/tree/master</p>
<p>Asset Plugin &#8211; better than rails 2.0 integrated</p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">http://synthesis.sbecker.net/pages/asset_packager</p>
<p>Image Magic</p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">http://vantulder.net/rails/magick/</p>
<p>OpenID</p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">http://wiki.rubyonrails.org/rails/pages/OpenidLoginGenerator</p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">http://github.com/technoweenie/restful-authentication/tree/master</p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">http://github.com/mrflip/</p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">Model graph visualize</p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px"><a href="http://www.franzens.org/?p=5">Article</a> on franzens.org</p>
<ul>
<li>http://visualizemodels.rubyforge.org/</li>
<li>http://rav.rubyforge.org/</li>
<li>http://railroad.rubyforge.org/</li>
</ul>
<h3>Simple Captcha</h3>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">http://expressica.com/simple_captcha/</p>
<h3>Memcached stuff</h3>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">http://townx.org/rails_and_memcached</p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px"><a href="http://www.thewebfellas.com/blog/2008/6/9/rails-2-1-now-with-better-integrated-caching ">Good rails 2.1 overview</a></p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">memcached -vv -l 127.0.0.1 -p 11211 -m 256 -P /tmp/memcached.pid -u mongrel</p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">memcached-tool 127.0.0.1</p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">monitor the connections with the hidden option in the memcached-tool</p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">echo $(($(netstat -nt | grep 11211 | grep -v WAIT | wc -l)/2)); ./memcached-tool 127.0.0.1:11211 dump &gt; memdump; cat memdump</p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px"><a href="http://www.gudasoft.com/wp-content/uploads/2008/05/memcached-tool">memcached-tool</a></p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px"><a href="http://blog.evanweaver.com/articles/2008/01/21/b-the-fastest-u-can-b-memcached/">alternative memcached client</a></p>
<p>PDF Output</p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">http://ruby-pdf.rubyforge.org/pdf-writer/</p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">http://rubyforge.org/projects/railspdfplugin/</p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">Somone example <a href="http://pastie.org/39098">report</a></p>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">Need to be checked: http://code.rubyreports.org/</p>
<p style="text-align: left;">
<h2><span style="font-family: -webkit-monospace;">Reporting</span></h2>
<pre><code><a href="http://www.oreillynet.com/pub/a/ruby/2008/04/08/ruport-business-reporting-for-ruby.html?page=1">ruport &amp; acts_as_reportable</a>
some <a href="http://wiki.rubyonrails.org/rails/pages/howtointegratejasperreports">java reporting </a>into rails</code></pre>
<h2>Sending Email</h2>
<p style="text-align: left; padding-left: 30px;">Inline email attachments plugin: http://flow.handle.it/past/2007/11/5/inline_attachment_now_official_rocks/</p>
<h2>Wiki integration</h2>
<p>http://github.com/queso/signal-wiki/tree/master</p>
<h2>Repositories</h2>
<p>http://github.com/mrflip/</p>
<h2>Tutorials</h2>
<p>Rails2.0 Video http://www.vimeo.com/425800</p>
<p>http://media.rubyonrails.org/video/rails_take2_with_sound.mov</p>
<p>http://akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial</p>
<p>http://akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial-part-2</p>
<h2>Performance and Loging</h2>
<p>http://austinentrepreneur.wordpress.com/2008/06/21/announcing-clientperf-simple-client-side-rails-performance/</p>
<h3>web statistics</h3>
<p>http://www.railstat.com/wiki/FAQ</p>
<p>http://haveamint.com/about/feature_highlights &#8211; not free</p>
<h3>production log analyzers</h3>
<p>webstat like: http://watson.rubyforge.org/</p>
<p>speed: http://github.com/wvanbergen/request-log-analyzer/wikis</p>
<p>speed: http://ckhsponge.wordpress.com/2006/10/11/ruby-on-rails-log-analyzer-rawk/</p>
<p>pl-analyse: http://seattlerb.rubyforge.org/production_log_analyzer  http://seattlerb.rubyforge.org/production_log_analyzer</p>
<h2>Open source rails projects</h2>
<ul>
<li>Search engines
<ul>
<li>http://www.opensourcerails.com/</li>
<li>http://github.com/repositories</li>
</ul>
</li>
<li>E-Commerce solutions
<ul>
<li><a href="http://code.google.com/p/substruct/">http://code.google.com/p/substruct/</a></li>
<li>http://spreehq.org/demo</li>
<li><a href="http://www.google.bg/search?hl=bg&amp;rlz=1C1CHMB_bgBG323BG323&amp;q=rails+open+source+e-commerce&amp;btnG=Търсене&amp;meta=">search google</a></li>
</ul>
</li>
</ul>
<h2>Server setup</h2>
<h3>capistrano</h3>
<ul>
<li><a href="http://weblog.jamisbuck.org/2007/7/23/capistrano-multistage">capistrano-multistage</a></li>
<li>gem install <a href="http://rubyforge.org/projects/rails-oceania/">seesaw</a> &#8211; restart app without loosing connections
<ul>
<li>mongrel_rails seesaw::configure &#8211;server nginx</li>
</ul>
</li>
</ul>
<h3>mod_rails</h3>
<ul>
<li style="http://www.gudasoft.com/wp-admin/padding-left: 30px">http://www.sysadminschronicles.com/articles/2008/05/13/ubuntu-8-04-rails-server-using-passenger-part-2</li>
</ul>
<h3>nginx</h3>
<ul>
<li>check my <a href="http://www.gudasoft.com/linux/administration-linux/08/19/104/nginx-with-rails/2008">post</a></li>
<li>gem install nginx_config_generator</li>
</ul>
<p style="http://www.gudasoft.com/wp-admin/padding-left: 30px">
]]></content:encoded>
			<wfw:commentRss>http://www.gudasoft.com/uncategorized/05/26/28/rails-plugins/2008/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
<enclosure url="http://media.rubyonrails.org/video/rails_take2_with_sound.mov" length="54364199" type="video/quicktime" />
		</item>
		<item>
		<title>will_paginate with ajax</title>
		<link>http://www.gudasoft.com/english/development/rails-development/05/16/38/will_paginate-with-ajax/2008</link>
		<comments>http://www.gudasoft.com/english/development/rails-development/05/16/38/will_paginate-with-ajax/2008#comments</comments>
		<pubDate>Fri, 16 May 2008 15:25:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://blog.gudasoft.com/?p=38</guid>
		<description><![CDATA[It is very easy to handle ajax pagination as described on this post here. I want to give one full example. Here is how my form looks: &#60;% form_remote_tag :url =&#62; { :action =&#62; 'handle_urls', :script_id =&#62; @script, :page =&#62; params[:page], }, :html =&#62; {:id =&#62; 'f'}, :update =&#62; "filtered_articles_pane" do %&#62; Here is how [...]]]></description>
			<content:encoded><![CDATA[<p>It is very easy to handle ajax pagination as described on this post <a href="http://weblog.redlinesoftware.com/2008/1/30/willpaginate-and-remote-links">here.</a></p>
<p>I want to give one full example.</p>
<p>Here is how my form looks:<br />
<code> </code></p>
<pre>&lt;% form_remote_tag :url =&gt; {
                      :action =&gt; 'handle_urls',
                      :script_id =&gt; @script,
                      :page =&gt; params[:page],
                    },
  :html =&gt; {:id =&gt; 'f'},
  :update =&gt; "filtered_articles_pane" do %&gt;</pre>
<p>Here is how my will_paginate helper looks:<br />
<code> </code></p>
<pre>&lt;%= will_paginate @filtered_urls,
  :renderer =&gt; 'RemoteLinkRenderer',
  :remote =&gt; { :with =&gt; "'script_id=#{@script.id}&amp;approved_flag='+$(\'approved_flag\')",
  :update =&gt; 'filtered_articles_pane'} %&gt;</pre>
<p>I have used the improved version of the will_paginate:<br />
<code> </code></p>
<pre># Use it like so…
# will_paginate :collection, :remote =&gt; {:with =&gt; 'value', :update =&gt; 'some_div'} 

class RemoteLinkRenderer &lt; WillPaginate::LinkRenderer
  def initialize(collection, options, template)
    @remote = options.delete(:remote)
    super
  end

  def page_link_or_span(page, span_class = 'current', text = nil)
    text ||= page.to_s
    if page and page != current_page
      @template.link_to_remote(text, {:url =&gt; url_options(page), :method =&gt; :get}.merge(@remote))
    else
      @template.content_tag :span, text, :class =&gt; span_class
    end
  end
end
</pre>
<h1>Update for will_paginate 2.3.x</h1>
<pre><code class="ruby"><span class="comment"># app/helpers/remote_link_renderer.rb</span>

<span class="keywords">class</span> <span class="constants">RemoteLinkRenderer</span> &lt; <span class="constants">WillPaginate</span>:<span class="symbol">:LinkRenderer</span>
  <span class="keywords">def</span> prepare<span class="brackets">(</span>collection, options, template<span class="brackets">)</span>
    <span class="instance">@remote</span> = options<span class="method">.delete</span><span class="brackets">(</span><span class="symbol">:remote</span><span class="brackets">)</span> || <span class="brackets">{</span><span class="brackets">}</span>
    super
  <span class="keywords">end</span>

protected
  <span class="keywords">def</span> page_link<span class="brackets">(</span>page, text, attributes = <span class="brackets">{</span><span class="brackets">}</span><span class="brackets">)</span>
    <span class="instance">@template</span><span class="method">.link_to_remote</span><span class="brackets">(</span>text, <span class="brackets">{</span><span class="symbol">:url</span> =&gt; url_for<span class="brackets">(</span>page<span class="brackets">)</span>, <span class="symbol">:method</span> =&gt; <span class="symbol">:get</span><span class="brackets">}</span><span class="method">.merge</span><span class="brackets">(</span><span class="instance">@remote</span><span class="brackets">)</span><span class="brackets">)</span>
  <span class="keywords">end</span>
<span class="keywords">end</span></code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.gudasoft.com/english/development/rails-development/05/16/38/will_paginate-with-ajax/2008/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rails 2.0 scaffolding</title>
		<link>http://www.gudasoft.com/english/development/rails-development/05/16/20/rails-20-scaffolding/2008</link>
		<comments>http://www.gudasoft.com/english/development/rails-development/05/16/20/rails-20-scaffolding/2008#comments</comments>
		<pubDate>Fri, 16 May 2008 07:24:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://blog.gudasoft.com/?p=20</guid>
		<description><![CDATA[The most valuable usage for scaffolding is when you use it in the administration part of the site. The administration is usually separated in separate module/folder. The new rails scaffolding is not good because: It is time taking to setup nested scaffold I have tons of uselss source code in the scaffolding like respond_to ... [...]]]></description>
			<content:encoded><![CDATA[<p>The most valuable usage for scaffolding is when you use it in the administration part of the site. The administration is usually separated in separate module/folder.</p>
<p>The new rails scaffolding is not good because:</p>
<ul>
<li>It is time taking to setup nested scaffold</li>
<li>I have tons of uselss source code in the scaffolding like <code>respond_to ... </code>that is usable very rare or never.</li>
<li>The HTML that is generated is ugly and not usable for CSS skin</li>
<li>Not using the nice ruby style iterations <code>.each</code> instead of <code>for's</code></li>
<li>Code repetition, the &#8220;new&#8221; and the &#8220;edit&#8221; views has the same form elements</li>
<li>Not easy to find documentation</li>
</ul>
<p>I find Akita <a onclick="pageTracker._trackPageview('/outgoing/www.akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial?referer=');" href="http://www.akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial">article</a> for scaffolding. It is is great that he has covered some real cases. It is a lot of reading and I must read/copy/paste every time I need to make a scaffold. Here is step by step on making scaffold for  administration.</p>
<ul>
<li><em><strong>ruby script/generate scaffold</strong> admin::BadArticle</em> NOT PLURAL!
<ul>
<li>user:<strong>references</strong></li>
<li>description:<strong>text,string</strong></li>
<li>fixed:<strong>boolean</strong></li>
<li>timestamps are automaticaly added</li>
</ul>
</li>
<li>Add in <strong>routes.rb</strong>
<ul>
<li><code> </code>
<pre>map.namespace :admin do |admin|
  admin.resources :bad_articles
end</pre>
</li>
</ul>
</li>
<li>Model
<ul>
<li>Rename <code><strong>admin::BadArticles -&gt; BadArticle</strong></code>,</li>
<li>move it to the model directory</li>
<li>rename the file</li>
</ul>
</li>
<li>Fix the migration file:
<ul>
<li> remove the prefix from the migration class,</li>
<li> remove the prefix from table name</li>
<li>rename the file</li>
</ul>
</li>
<li>URL references
<ul>
<li><strong>admin</strong>_bad_articles_url</li>
<li> redirect_to([:admin, bad_article])</li>
</ul>
</li>
<li>Controller
<ul>
<li>rename all Admin::BadArticles -&gt; BadArticle except in the controller name</li>
<li>Probably you will want to make your scaffold inhired your base admin controller</li>
<li><code> </code>
<pre>def create
   ...
   format.html { redirect_to(<strong>[:admin</strong>, @filtered_url<strong>]</strong>) }
   ...
end</pre>
</li>
<li>
<pre>def update
    ...
        format.html { redirect_to(<strong>[:admin,</strong> @filtered_url<strong>]</strong>) }
    ...
end</pre>
</li>
<li><code> </code>
<pre>class Admin::BadArticlesController &lt; ApplicationController</pre>
<pre>class Admin::BadArticlesController &lt; <strong>Admin::AuthController</strong>
  <span style="color: #888888;">layout 'admin'</span>
 (in case that you don't have it in the base controller)</pre>
</li>
<li>
<pre>def index
  @<span style="text-decoration: line-through;">admin_</span>bad_articles = BadArticle.find(:all)
  respond_to do |format|
    format.html # index.html.erb
    format.xml  { render :xml =&gt; @<span style="text-decoration: line-through;">admin_</span>bad_articles }
  end
end</pre>
</li>
</ul>
</li>
<li>Index.rhtml.erb
<ul>
<li><code> </code>
<pre>&lt;td&gt;&lt;%= link_to 'Edit', edit_<strong>admin</strong>_bad_article_path(bad_articles) %&gt;&lt;/td&gt;</pre>
</li>
<li><code> </code>
<pre>&lt;%= link_to 'New bad_articles', new_<strong>admin_</strong>bad_articles_path %&gt;</pre>
</li>
</ul>
</li>
<li>edit.rhtm
<ul>
<li><code> </code>
<pre>&lt;%= link_to 'Show', @bad_article %&gt; |
&lt;%= link_to 'Back',bad_articles_path %&gt;&lt;%= link_to 'Show', <strong>[:admin</strong>, @bad_article_url<strong>]</strong> %&gt; |
&lt;%= link_to 'Back', <strong>admin_</strong>bad_articles_path %&gt;</pre>
</li>
</ul>
</li>
<li>show.html.erb
<ul>
<li><code> </code>
<pre>&lt;%= link_to 'Edit', edit_filtered_url_path(@filtered_url) %&gt; |
&lt;%= link_to 'Back', filtered_urls_path %&gt;</pre>
</li>
</ul>
</li>
<li>new.rhtml
<ul>
<li><code> </code>
<pre>&lt;% form_for(@bad_article) do |f| %&gt;&lt;% form_for(<strong>[:admin,</strong> @bad_article<strong>]</strong>) do |f| %&gt;</pre>
</li>
<li><code> </code>
<pre>&lt;%= link_to 'Back', bad_articles_path %&gt;&lt;%= link_to 'Back', <strong>admin_</strong>bad_articles_path %&gt;</pre>
</li>
</ul>
</li>
</ul>
<h1>Traps:</h1>
<p>The order of the routes in routes.rb does matter! In order to make the REST work you must have this block at the bottom of your routes.rb like this:</p>
<pre>map.namespace :admin do |admin|
  admin.resources :bad_articles
end</pre>
<pre># Install the default route as the lowest priority.
map.connect ':controller/:action/:id.:format'
map.connect ':controller/:action/:id'</pre>
<p><code><br />
Remove simply_helpful plugin if you get the error:</code></p>
<pre>undefined method `new_record?' for #Array:0x532a3e8</pre>
<h1>Debuging tools:</h1>
<p>rake routes</p>
<h1>Tips:</h1>
<p>How to add custom actions to the REST</p>
<pre>map.namespace :admin do |admin|
  admin..esources :bad_articles, :member =&gt; {:toggle =&gt; :get}
  admin.resources :orders, :member =&gt; { :resend =&gt; :post }
  admin.resources :users,  :collection =&gt; { :filter =&gt; :any }
end</pre>
<p>Then in the controller:</p>
<pre>def toggle
  @bad_article = BadArticle.find(params[:id])
  @bad_article.fixed = ! @bad_article.fixed
  @bad_article.save
  redirect_to  admin_bad_articles_url
end</pre>
<p>And in the view:</p>
<pre>&lt;%= toggle_admin_bad_article_url(filtered_url) %&gt;</pre>
<p>More reading <a onclick="pageTracker._trackPageview('/outgoing/railscasts.com/episodes/35?referer=');" href="http://railscasts.com/episodes/35">here</a></p>
<h1>Resources:</h1>
<ul>
<li><a href="http://www.gudasoft.com/wp-content/uploads/2008/05/restful_rails_en.pdf">restful_rails_en</a></li>
<li>Akita <a onclick="pageTracker._trackPageview('/outgoing/www.akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial?referer=');" href="http://www.akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial">article</a></li>
<li><a href="http://frozenplague.net/2008/01/06/restful-routing-an-overview/">http://frozenplague.net/2008/01/06/restful-routing-an-overview/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.gudasoft.com/english/development/rails-development/05/16/20/rails-20-scaffolding/2008/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails code-snipplets</title>
		<link>http://www.gudasoft.com/english/development/rails-development/05/12/25/rails-code-snipplets/2008</link>
		<comments>http://www.gudasoft.com/english/development/rails-development/05/12/25/rails-code-snipplets/2008#comments</comments>
		<pubDate>Mon, 12 May 2008 10:58:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://blog.gudasoft.com/?p=25</guid>
		<description><![CDATA[auto_scope source: http://blog.teksol.info/archives/2007/3 class Contact &#60; ActiveRecord::Base auto_scope \ :old =&#62; {:find =&#62; {:conditions =&#62; ["born_on &#60; ?", 30.years.ago]}}, :young =&#62; {:find =&#62; {:conditions =&#62; ["born_on &#62; ?", 1.year.ago]}} end class Testimonial &#60; ActiveRecord::Base auto_scope \ :approved =&#62; { :find =&#62; {:conditions =&#62; ["approved_at &#60; ?", proc {Time.now}]}, :create =&#62; {:approved_at =&#62; proc {Time.now}}}, :unapproved [...]]]></description>
			<content:encoded><![CDATA[<h1>auto_scope</h1>
<p><span class="r">source: http://blog.teksol.info/archives/2007/3</span></p>
<p>class <span class="cl">Contact</span> &lt; <span class="co">ActiveRecord</span>::<span class="co">Base</span><tt><br />
</tt> auto_scope \<tt><br />
</tt> <span class="sy">:old</span> =&gt; {<span class="sy">:find</span> =&gt; {<span class="sy">:conditions</span> =&gt; [<span class="s"><span class="dl">"</span><span class="k">born_on &lt; ?</span><span class="dl">"</span></span>, <span class="i">30</span>.years.ago]}},<tt><br />
</tt> <span class="sy">:young</span> =&gt; {<span class="sy">:find</span> =&gt; {<span class="sy">:conditions</span> =&gt; [<span class="s"><span class="dl">"</span><span class="k">born_on &gt; ?</span><span class="dl">"</span></span>, <span class="i">1</span>.year.ago]}}<tt><br />
</tt><span class="r">end</span><tt><br />
</tt><tt><br />
</tt><span class="r">class</span> <span class="cl">Testimonial</span> &lt; <span class="co">ActiveRecord</span>::<span class="co">Base</span><tt><br />
</tt> auto_scope \<tt><br />
</tt> <span class="sy">:approved</span> =&gt; {<tt><br />
</tt> <span class="sy">:find</span> =&gt; {<span class="sy">:conditions</span> =&gt; [<span class="s"><span class="dl">"</span><span class="k">approved_at &lt; ?</span><span class="dl">"</span></span>, proc {<span class="co">Time</span>.now}]},<tt><br />
</tt> <span class="sy">:create</span> =&gt; {<span class="sy">:approved_at</span> =&gt; proc {<span class="co">Time</span>.now}}},<tt><br />
</tt> <span class="sy">:unapproved</span> =&gt; {<tt><br />
</tt> <span class="sy">:find</span> =&gt; {<span class="sy">:conditions</span> =&gt; <span class="s"><span class="dl">&#8220;</span><span class="k">approved_at IS NULL</span><span class="dl">&#8220;</span></span>},<tt><br />
</tt> <span class="sy">:create</span> =&gt; {<span class="sy">:approved_at</span> =&gt; <span class="pc">nil</span>}}<tt><br />
</tt><span class="r">end</span></p>
<h2>Rails internals!?</h2>
<p>http://localhost:3000/rails/info/properties</p>
<h2>Threads</h2>
<ul>
<li>nice <a href="http://bibwild.wordpress.com/2007/08/28/threading-in-rails/ActiveRecord::Base.verify_active_connections!()">post</a> on custom thread handling</li>
<li><a href="http://rubyforge.org/forum/forum.php?forum_id=18237">spawn</a> plugin</li>
<li>the <a href="http://corelib.rubyonrails.org/classes/Thread.html">api</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.gudasoft.com/english/development/rails-development/05/12/25/rails-code-snipplets/2008/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

