title: Good practice for controller actions when creating subdomains for different user types
body: <p>I am creating subdomains for different user types and was wondering what is a good practice in doing so. I have user type <code>admin</code>, <code>editor</code> and <code>grader</code>, and their subdomains <code>admin.somesite.com</code>, <code>editor.somesite.com</code> and <code>grader.somesite.com</code>.</p>
  
  <p>The problem on which I run into is how to model connection between controller action and certain user type. If I have the following for root for subdomain <code>admin</code>:</p>
  
  <pre><code>match '/' =&gt; 'supers#main_site', :constraints =&gt; { :subdomain =&gt; 'admin' }
  </code></pre>
  
  <p>And I have a model of <code>Article</code> which can be edited by <code>editor</code> and <code>admin</code>. I already implemented verification for <code>edit</code> action inside <code>ArticlesController</code> which checks if the logged-in user is <code>editor</code> or <code>admin</code>. If not, I transfer him to error site.</p>
  
  <p>My question is do I need to limit somehow Article edits to specific domains like this:</p>
  
  <pre><code>match '/articles/:id/edit' =&gt; 'articles#edit', :constraints =&gt; { :subdomain =&gt; 'admin' }
  match '/articles/:id/edit' =&gt; 'articles#edit', :constraints =&gt; { :subdomain =&gt; 'editor' }
  </code></pre>
  
  <p>Or it is enough to just navigate to article editing while I am already navigating inside that domain? So, if <code>editor</code> is already logged in on his domain <code>editor.somesite.com</code> and he clicks to edit article on his home page it will normally bring him to <code>editor.somesite.com/articles/:id/edit</code> and if <code>admin</code> does it, he will see <code>admin.somesite.com/articles/:id/edit</code>.</p>
  
  <p>What would be a good practice with multiple subdomains and permissions? Thanks!</p>