<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>RubyOnRailsTips</title>
	<atom:link href="http://railstips.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://railstips.wordpress.com</link>
	<description>еще один рельсовый блог</description>
	<lastBuildDate>Mon, 04 Feb 2008 22:10:17 +0000</lastBuildDate>
	<language>ru</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='railstips.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>RubyOnRailsTips</title>
		<link>http://railstips.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://railstips.wordpress.com/osd.xml" title="RubyOnRailsTips" />
	<atom:link rel='hub' href='http://railstips.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Использования simple_captcha для защиты от спама</title>
		<link>http://railstips.wordpress.com/2007/10/11/simple-captcha/</link>
		<comments>http://railstips.wordpress.com/2007/10/11/simple-captcha/#comments</comments>
		<pubDate>Wed, 10 Oct 2007 21:33:03 +0000</pubDate>
		<dc:creator>shuller</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[captcha]]></category>
		<category><![CDATA[simple_captcha]]></category>

		<guid isPermaLink="false">http://railstips.wordpress.com/2007/10/11/simple-captcha/</guid>
		<description><![CDATA[Не смотря на то, что в очень популярной статье Ruby on Rails Security Guide пишеться о том, что simple_captcha не самый лучший вариант для защиты от спама именно о нем и пойдет речь далее. Установка Как и для всех других плагинов для установки в консоле пишем следуйщие: svn://rubyforge.org/var/svn/expressica/plugins/simple_captcha Для корректной работы плагина потребуется Rmagick. Установка [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=railstips.wordpress.com&amp;blog=1884534&amp;post=5&amp;subd=railstips&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Не смотря на то, что в очень популярной статье <a href="http://www.quarkruby.com/2007/9/20/ruby-on-rails-security-guide" title="Ruby on Rails Security Guide  " target="_blank">Ruby on Rails Security Guide</a> пишеться о том, что <a href="http://expressica.com/2007/03/23/simple_captcha_1_0/">simple_captcha</a> не самый лучший вариант для защиты от спама именно о нем и пойдет речь далее.  <b>    Установка </b> Как и для всех других плагинов для установки в консоле пишем следуйщие:<br />
<code><br />
svn://rubyforge.org/var/svn/expressica/plugins/simple_captcha</code><br />
Для корректной работы плагина потребуется <a href="http://rubyforge.org/projects/rmagick/">Rmagick</a>. Установка Rmagick выходит за рамки этого поста, но я думаю что в скором времени высветлю этот вопрос.  <b>    Использование </b>  Если вам не нужна поддержка валидации на уровне модели, тогда достаточно вызвать хелпер плагина в вашем rhtml:</p>
<p><code>&lt;%= show_simple_captcha %&gt;</code></p>
<p>а в контроллере</p>
<p><code>if simple_captcha_valid?</code><br />
переход дальше<br />
<code>else</code><br />
перегрузить текущую страничку с ошибкой<br />
<code>end</code></p>
<p>В проэкте над которым я работаю это выглядело следуйщим образом:</p>
<p><code>def share<br />
@post = Post.find(:first,:conditions =&gt; ["can_publish=1 and is_edited=1 and id=?", params[:slug].to_i])<br />
if simple_captcha_valid?<br />
if params[:email] =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i<br />
email = PostMailer.create_share(@post, params[:email])<br />
blind_email = PostMailer.create_blind(@post, params[:from_email], params[:email],<br />
params[:emailmessage])<br />
PostMailer.deliver(email)<br />
PostMailer.deliver(blind_email)<br />
PostShare.create(<br />
:post =&gt; @post,<br />
:email =&gt; params[:email],<br />
:from_email =&gt; params[:from_email],<br />
:message =&gt; params[:emailmessage])<br />
flash[:notice] = "You have sent a link for this article to #{params[:email]}."</p>
<p>end</p>
<p>render :template =&gt; 'posts/show'</p>
<p>else</p>
<p>flash[:notice] = "You have entered wrong combination from the picture. Please try again."</p>
<p>redirect_to post_url(@post.permalink)</p>
<p>end</p>
<p>end</code></p>
<p>Если вас не устраивает как хелпер разставляет теги вы можете заменить разметку на свою в файле ../vendor/plugins/simple_catcha/simple_captcha_action_view в методе show_simple_captcha.  <b>Использование с валидацией модели</b>  Допустим у вас есть модель Responce, которая отвечает за добавление откликов о товаре на сайте. Тогда в моделе добавлем:</p>
<blockquote><p><code> </code></p>
<pre>class Response &lt; ActiveRecord::Base apply_simple_captcha</pre>
</blockquote>
<p>В вьюшку добавляем хелпер и сабмит-кнопку для отправки запроса в контроллер</p>
<blockquote>
<pre> "response"</pre>
</blockquote>
<p>В контроллере же вызываем метод-хелпер который проверяет поддтверждена ли картинка и сохраняет новую запись в базу:</p>
<blockquote><p><code> </code></p>
<pre>def add_response 	@response = Response.new(params[:response])@response.save_with_captcha

end</pre>
</blockquote>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/railstips.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/railstips.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/railstips.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/railstips.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/railstips.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/railstips.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/railstips.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/railstips.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/railstips.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/railstips.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/railstips.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/railstips.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/railstips.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/railstips.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/railstips.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/railstips.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=railstips.wordpress.com&amp;blog=1884534&amp;post=5&amp;subd=railstips&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://railstips.wordpress.com/2007/10/11/simple-captcha/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/54809886be03c8e0bd219efff9a2b1ca?s=96&#38;d=identicon" medium="image">
			<media:title type="html">shuller</media:title>
		</media:content>
	</item>
		<item>
		<title>Первый пошел</title>
		<link>http://railstips.wordpress.com/2007/10/10/first/</link>
		<comments>http://railstips.wordpress.com/2007/10/10/first/#comments</comments>
		<pubDate>Wed, 10 Oct 2007 19:48:48 +0000</pubDate>
		<dc:creator>shuller</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://railstips.wordpress.com/2007/10/10/%d0%9f%d0%b5%d1%80%d0%b2%d1%8b%d0%b9-%d0%bf%d0%be%d1%88%d0%b5%d0%bb/</guid>
		<description><![CDATA[Просто тестовый пост.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=railstips.wordpress.com&amp;blog=1884534&amp;post=4&amp;subd=railstips&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Просто тестовый пост.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/railstips.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/railstips.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/railstips.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/railstips.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/railstips.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/railstips.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/railstips.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/railstips.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/railstips.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/railstips.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/railstips.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/railstips.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/railstips.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/railstips.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/railstips.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/railstips.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=railstips.wordpress.com&amp;blog=1884534&amp;post=4&amp;subd=railstips&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://railstips.wordpress.com/2007/10/10/first/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/54809886be03c8e0bd219efff9a2b1ca?s=96&#38;d=identicon" medium="image">
			<media:title type="html">shuller</media:title>
		</media:content>
	</item>
	</channel>
</rss>
