title: How to assign different user roles during registration?
body: <p>I was wondering how can I create different user roles depending on which part of the site user registers? For example, I have three user types. One is admin, another is regular user and third one is moderator.</p>
  
  <p>I have the following table:</p>
  
  <pre><code>create_table "users", force: true do |t|
      t.string   "username"
      t.string   "email"
      t.string   "role"
      t.string   "password"
  end
  </code></pre>
  
  <p>Inside "role" column I would save one of the following strings: "admin", "regular" or "moderator". </p>
  
  <p>I have already created my authentication system with the help of <a href="http://ruby.railstutorial.org/chapters/beginning#top" rel="nofollow">Michael Hartl's Ruby on Rails Tutorial</a>. Also, I watched railscasts episode <a href="http://railscasts.com/episodes/189-embedded-association" rel="nofollow">#189 Embedded Association</a> where there is a really nice approach of handling multiple user roles.</p>
  
  <p>The problem is that on video user roles are chosen during registration and I don't want user to see user roles. I have two sections of the site. If user registers through one section he will have a role "regular" and if he registers through another section he will have role "moderator". Role "admin' would of course be set differently.</p>
  
  <p>It could be done if I pass parameter "role": "moderator" or "role": "regular" but that doesn't seem to me as the safe option because it would be visible to users and they can easily pass some other parameter there. For example regular users who want to harm the site could pass "role": "moderator".</p>
  
  <p>Thank you for your advices :)</p>