<?xml version="1.0" encoding="UTF-8"?>
<rss version='2.0' xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Prelang</title>
    <description>Automatic Rails Development Tools</description>
    <link>https://prelang.silvrback.com/feed</link>
    <atom:link href="https://prelang.silvrback.com/feed" rel="self" type="application/rss+xml"/>
    <category domain="prelang.silvrback.com">Content Management/Blog</category>
    <language>en-us</language>
      <pubDate>Fri, 25 Apr 2014 15:08:41 -0400</pubDate>
    <managingEditor>administrator@prelang.com (Prelang)</managingEditor>
      <item>
        <guid>http://blog.prelang.com/using-dotenv-in-rails-for-environment-variables#3256</guid>
          <pubDate>Fri, 25 Apr 2014 15:08:41 -0400</pubDate>
        <link>http://blog.prelang.com/using-dotenv-in-rails-for-environment-variables</link>
        <title>Using Dotenv in Rails for Environment Variables</title>
        <description>Automatically Installing Dotenv with Prelang</description>
        <content:encoded><![CDATA[<p><a href="http://prelang.com">Sign up for Prelang</a> to use this feature.</p>

<h1 id="installation">Installation</h1>

<p><strong>Prelang automates the process of installing Dotenv</strong>, an environment variable management gem for <strong>Ruby on Rails</strong>.  This guide will explain how to install Dotenv and use it after your application generates.</p>

<ol>
<li> Find and add the <em>Environment Variables</em> feature</li>
<li> Generate your application</li>
</ol>

<p><a href="http://prelang.com"><img alt="Dotenv" src="https://silvrback.s3.amazonaws.com/uploads/edaae479-8207-43c1-b32f-6d00778576e3/Dotenv_large.png" /></a></p>

<p>This will add and configure the <em>Dotenv</em> Rails gem.</p>

<hr>

<h2 id="after-generation">After Generation</h2>

<p>Once you have your application up and running locally on your development environment, make a new file in your application&#39;s directory named <code>.env</code>.  Here, you can put sensitive environment variables as so:</p>
<div class="highlight"><pre><span></span>FACEBOOK_SECRET_ID=123123123123123
SENDGRID_SECRET_KEY=234234234234234
</pre></div>
<p>Your environment variables will now be accessible from anywhere in your Rails application.  Use them with <code>ENV</code> like this:</p>
<div class="highlight"><pre><span></span><span class="no">ENV</span><span class="o">[</span><span class="s2">&quot;FACEBOOK_SECRET_ID&quot;</span><span class="o">]</span>
</pre></div>
<p>Usually, these are use in initializers at <code>config/initializers/</code>.</p>

<p><a href="http://prelang.com"><img alt="Try Prelang" src="https://silvrback.s3.amazonaws.com/uploads/4d3c9622-0020-41cb-a96a-a3961878671c/Try%20Prelang_large.png" /></a></p>
]]></content:encoded>
      </item>
      <item>
        <guid>http://blog.prelang.com/devise-for-authentication-on-rails-4#3229</guid>
          <pubDate>Fri, 25 Apr 2014 13:38:01 -0400</pubDate>
        <link>http://blog.prelang.com/devise-for-authentication-on-rails-4</link>
        <title>Devise for Authentication on Rails 4</title>
        <description>Automatically Installing User Login with Prelang</description>
        <content:encoded><![CDATA[<p><a href="http://prelang.com">Sign up for Prelang</a> to use this feature.</p>

<h1 id="installation">Installation</h1>

<p><strong>Prelang automates the entire process of installing Devise</strong>, an excellent user authentication gem for <strong>Ruby on Rails</strong> 4, which handles user login for your application.  This guide will go over what the <em>User Login</em> feature adds and explain all of the options which Prelang supports.</p>

<p><a href="http://prelang.com"><img alt="Devise Installation" src="https://silvrback.s3.amazonaws.com/uploads/b51b3f62-dbc5-46de-afe8-962bd124013d/Devise.000_large.png" /></a></p>

<p><strong>Adding this feature will automatically perform these steps on your application:</strong></p>

<ul>
<li>  Installs Devise (gem, initializer, etc.)</li>
<li>  Generates a <em>User</em> model (See below)</li>
<li>  Defines a <code>require_user_signed_in</code> filter in <code>ApplicationController</code> for use in other controllers.  If set, this requires the user to be signed in to view certain controllers or actions.</li>
</ul>

<p><a href="http://prelang.com"><img alt="User Model" src="https://silvrback.s3.amazonaws.com/uploads/90345a7f-b188-4322-9b53-949fe997a2b6/Devise.User%20Model_large.png" /></a></p>

<p><strong>After adding the feature, you will be presented with a list of options.</strong></p>

<h3 id="facebook-login-support">Facebook Login Support</h3>

<p>Allowing users to login to your application with Facebook can easily be achieved by toggling this option.  This adds the <code>omniauth</code> and <code>omniauth-facebook</code> gems and injects a few methods into your <em>User</em> model to store and find users by their Facebook IDs.  It also creates a migration for adding <code>uid</code> to <em>User</em>.</p>

<p><em>Note: See Post Generation Steps</em></p>

<h3 id="editable-views">Editable Views</h3>

<p>This option will generate views at <code>app/views/devise</code> which you can use to customize the default Devise views for <em>Login</em>, <em>Sign Up</em>, and <em>Account</em> which allows you to add your own styling and layout.</p>

<h3 id="editable-controllers">Editable Controllers</h3>

<p>Similarly, the <em>Editable Controllers</em> will generate controllers at <code>app/controllers/users</code> which allow you to customize the behavior of Devise controllers.  Each of them calls a <code>super</code> method to hook into the original Devise controllers.</p>

<h3 id="username-login-support">Username Login Support</h3>

<p>This option will add a <em>username</em> string attribute to the <em>User</em> model (with a migration) and allow users to login with either a username or email address.  It updates the Devise views for <em>Sign Up</em> (to add a <em>username</em> field) and <em>Login</em> (to add a universal field for either email or username) and plays nicely with the <em>UI Framework / Twitter Bootstrap</em> feature.</p>

<h3 id="stylized-paths">Stylized Paths</h3>

<p>The default Devise paths look something like this: <code>/users/sign_up</code>.  Many users want to change these paths to prettier ones like <code>/signup</code> and <code>/login</code> so toggling this option will do just that.  All of the changes will live in<code>routes.rb</code>.</p>

<hr>

<h2 id="after-generation">After Generation</h2>

<p>If you&#39;ve toggled the <em>Facebook Login</em> option, you&#39;ll need to set your <code>FACEBOOK_SECRET_ID</code> ENV variable.  Adding the <a href="/using-dotenv-in-rails-for-environment-variables"><em>ENV Variables</em></a> feature makes this easy... You&#39;ll only need to set that in your <code>.env</code> file on development.</p>

<p><a href="http://prelang.com"><img alt="Try Prelang" src="https://silvrback.s3.amazonaws.com/uploads/4d3c9622-0020-41cb-a96a-a3961878671c/Try%20Prelang_large.png" /></a></p>
]]></content:encoded>
      </item>
  </channel>
</rss>