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

<channel>
	<title>plugin « Plataformatec Blog</title>
	<atom:link href="/tag/plugin/feed/" rel="self" type="application/rss+xml" />
	<link>/</link>
	<description>Plataformatec&#039;s place to talk about Ruby, Ruby on Rails, Elixir, and software engineering</description>
	<lastBuildDate>Mon, 16 Nov 2009 01:04:13 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.4.2</generator>
	<item>
		<title>Devise: authentication for lazy programmers</title>
		<link>/2009/11/devise-authentication-for-lazy-programmers/</link>
					<comments>/2009/11/devise-authentication-for-lazy-programmers/#comments</comments>
		
		<dc:creator><![CDATA[José Valim]]></dc:creator>
		<pubDate>Wed, 04 Nov 2009 13:24:25 +0000</pubDate>
				<category><![CDATA[English]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[devise]]></category>
		<category><![CDATA[generators]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[rails]]></category>
		<guid isPermaLink="false">/?p=410</guid>

					<description><![CDATA[<p>It has been a couple weeks since we first bloged about Devise. At that time, we released version 0.1 and now, after some great feedback, some enhancements and a few bugs fixes, we reached Devise 0.4. So, what changed since then? I&#8217;m lazy, you&#8217;re lazy Devise now comes with generators, so adding up authentication to ... <a class="read-more-link" href="/2009/11/devise-authentication-for-lazy-programmers/">»</a></p>
<p>The post <a href="/2009/11/devise-authentication-for-lazy-programmers/">Devise: authentication for lazy programmers</a> first appeared on <a href="/">Plataformatec Blog</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>It has been a couple weeks since we <a href="/2009/10/devise-flexible-authentication-solution-for-rails/">first bloged</a> about <a href="http://github.com/plataformatec/devise">Devise</a>. At that time, we released version 0.1 and now, after some great feedback, some enhancements and a few bugs fixes, we reached Devise 0.4. So, what changed since then?</p>
<h3>I&#8217;m lazy, you&#8217;re lazy</h3>
<p>Devise now comes with generators, so adding up authentication to your app is even easier and quicker to do. First, let&#8217;s install <a href="http://github.com/plataformatec/devise">Devise</a> if you haven&#8217;t yet:</p>
<pre lang="ruby">
gem sources -a http://gemcutter.org/
gem install devise
</pre>
<p>And let&#8217;s add it to your environment, all together with <a href="http://github.com/hassox/warden">warden</a>:</p>
<pre lang="ruby">
config.gem "warden", :version => "0.5.1"
config.gem "devise", :version => "0.4.1"
</pre>
<p>After setting the gem up, the first generator can be invoked:</p>
<pre lang="ruby">
script/generate devise_install
</pre>
<p>And it simply places an initializer at config/initializers/devise.rb. You can check there all devise configuration options, so the initializer fits well as documentation tool too. Some of the new things you can configure since 0.1 release is the :confirm_within period (the time the user can access the site even without confirming his account) and :remember_for period (the time the remember token is valid). </p>
<p>After we configured <a href="http://github.com/plataformatec/devise">Devise</a>, we are able create our models. And how hard can that be if we have a generator? So just do:</p>
<pre lang="ruby">
script/generate devise User
</pre>
<p>It&#8217;s going to create a model User, add map.devise_for :users in routes.rb and a migration file. And before we proceed, we just need to configure default_url_options for ActionMailer in config/environments/development.rb (the config below is for development, be sure to properly set them for test and production too):</p>
<pre lang="ruby">
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
</pre>
<p>And have at least a route named root in our config/routes.rb (by default, devise will look for user_root_path, if none is defined, is uses root_path):</p>
<pre lang="ruby">
map.root :controller => "your_controller"
</pre>
<p>Now we just need to run migrations and we will be able to create our first user in the console:</p>
<pre lang="ruby">
User.create!(:email => "your@email.com", :password => "secret")
</pre>
<p>Now just start your web server and you will be able to sign your user in at /users/sign_in, request for another confirmation code to be sent, request a code to reset your password and so forth.</p>
<p>Just remember that <span style="text-decoration:underline">Devise does not say anything about the sign up process</span>, that&#8217;s why you have to create your users in console.</p>
<h3>Customization</h3>
<p>We also know that you want to customize your views, to use something like <a href="http://github.com/justinfrench/formtastic">Formtastic</a> instead of the default markup. Well, guess who is here to help you?</p>
<p>Generators! The command below will make a copy of all devise views to your application, including locale files, for flash messages configuration:</p>
<pre lang="ruby">
script/generate devise_views
</pre>
<h3>Laziness for all!</h3>
<p>We know that you are lazy and not just with ActiveRecord. You want to be lazy with Datamapper, Mongomapper, Couchrest&#8230; This is why we worked on making <a href="http://github.com/plataformatec/devise/commit/e7f809de3c78ab413e43010e4df3bb65556440b3">Devise a little bit more agnostic</a>, all your ORM has to do is have an API similar to ActiveRecord (finder and callbacks mainly).</p>
<p>Besides, if you already travelled a bit on Warden world, you will see that there is a lot more than Devise, including some strategies for <a href="http://github.com/roman/warden_oauth">OAuth</a>. So we are also working on making Devise compatible with such new strategies as well, that&#8217;s why you can already see a config.warden hook on the initializer.</p>
<h3>Deprecations</h3>
<p>Since things are getting really easy, we need to ask something back from you. Just watch out for to deprecations in <a href="http://github.com/plataformatec/devise">Devise</a> 0.4.0:</p>
<p>1) :authenticable is a typo, so we fixed that renaming it to :authenticatable. If you used Devise 0.3.x, you could see some deprecation warnings. However, in Devise 0.4.0 such warnings were removed. Tip: be sure to check your migration!</p>
<p>2) We had a notifier inside <a href="http://github.com/plataformatec/devise">Devise</a> called Notifier. We decided to follow <a href="http://github.com/thoughtbot/clearance">Clearance</a> convention and rename it to DeviseMailer. You will need to change your views from notifier to devise_mailer and your locale yml from notifier to mailer.</p>
<p>We hope you enjoy <a href="http://github.com/plataformatec/devise">Devise</a> as much as we do! And, as previously, we also have <a href="http://github.com/plataformatec/devise_example">an example app in Github</a> to help you get started too.</p><p>The post <a href="/2009/11/devise-authentication-for-lazy-programmers/">Devise: authentication for lazy programmers</a> first appeared on <a href="/">Plataformatec Blog</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>/2009/11/devise-authentication-for-lazy-programmers/feed/</wfw:commentRss>
			<slash:comments>36</slash:comments>
		
		
			</item>
	</channel>
</rss>
