title: Ruby on Rails setting two users as admin w/ ldap authentication
body: <p>New to Ruby on Rails and I have a show page which has information that has been filled out from the new page including radio buttons which allow or deny the request form. I'd like every person that's able to login using the ldap authentication that's set up already to be able to view the show page information. But I need only two users, which will be admins, to be able to see the radio buttons to allow or deny the request form. I've used many different tutorials and the similar question i've seen online doesn't really help me out. The is_admin? method in the articles_controllers is not a real method and would like help with that. The users that login with their ldap credentials username is in the form of "john_smith". I apologize in advance for my poor coding skills. If there is any additional information needed I can supply that fairly quickly. </p>
  
  <p>This is the code for the show page. app\views\articles\show.html.erb</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;style&gt;
  p.inq
  {
      width:400px; 
      word-wrap:break-word;;
  }
  &lt;/style&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="logo"&gt;&lt;/div&gt;
  &lt;center&gt;
  &lt;h1&gt; Submitted Request &lt;/h1&gt;
  &lt;table&gt;&lt;tr&gt;&lt;p&gt;
  
  &lt;td&gt;&lt;strong&gt;Approval Status:&lt;/strong&gt;&lt;/td&gt;
   &lt;td&gt;  &amp;nbsp &amp;nbsp &amp;nbsp       &lt;/td&gt;  
   &lt;td&gt;&lt;%= @article.approve %&gt;&lt;/td&gt;&lt;/p&gt;&lt;/tr&gt;
    &lt;p&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Name:&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;  &amp;nbsp &amp;nbsp &amp;nbsp       &lt;/td&gt;
      &lt;td&gt;&lt;%= @article.name %&gt;&lt;/td&gt;
    &lt;/p&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;p&gt;
      &lt;td&gt;&lt;strong&gt;Email:&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;       &lt;/td&gt;
      &lt;td&gt;&lt;%= @article.email %&gt;&lt;/td&gt;
    &lt;/p&gt;&lt;/tr&gt;
    &lt;tr&gt; &lt;p&gt;
      &lt;td&gt;&lt;strong&gt;Phone Number:&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;       &lt;/td&gt;
      &lt;td&gt;&lt;%= @article.phone_number %&gt;&lt;/td&gt;
    &lt;/p&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;p&gt;  
      &lt;td&gt;&lt;strong&gt;Department Name&lt;/strong&gt;&lt;/td&gt;
    &lt;td&gt;      &lt;/td&gt;
    &lt;td&gt;&lt;%= @article.dept_name %&gt;&lt;/td&gt;
    &lt;/p&gt;&lt;/tr&gt;
  
        &lt;tr&gt;&lt;p&gt;  
      &lt;td&gt;&lt;strong&gt;Desc. of Business Need:&lt;/strong&gt;&lt;/td&gt;
        &lt;td&gt;      &lt;/td&gt;
    &lt;td&gt;&lt;%= @article.dob %&gt;&lt;/td&gt;
    &lt;/p&gt;&lt;/tr&gt;
  
    &lt;tr&gt;&lt;p&gt;  
      &lt;td&gt;&lt;strong&gt;Desc. of Changes to Firewall:&lt;/strong&gt;&lt;/td&gt;
    &lt;td&gt;      &lt;/td&gt;
    &lt;td&gt;&lt;%= @article.doc %&gt;&lt;/td&gt;
    &lt;/p&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;p&gt;  
  
      &lt;tr&gt;&lt;p&gt;  
      &lt;td&gt;&lt;strong&gt;Additional Information(NAT's, VIPS's, Servers, etc.:&lt;/strong&gt;&lt;/td&gt;
    &lt;td&gt;      &lt;/td&gt;
    &lt;td&gt;&lt;%= @article.info %&gt;&lt;/td&gt;
    &lt;/p&gt;&lt;/tr&gt;
  
      &lt;tr&gt;&lt;p&gt;
      &lt;td&gt;&lt;strong&gt;Inquiry:&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;     &lt;/td&gt;
      &lt;td&gt;&lt;p class="inq"&gt;&lt;%= @article.inquiry %&gt;&lt;/p&gt;&lt;/td&gt;
    &lt;/p&gt;&lt;/tr&gt;&lt;/table&gt;
    &lt;%= :username %&gt;
    &lt;% if is_admin? %&gt;
  
    &lt;%= form_for :article, :method =&gt; :patch, url: article_path(@article) do |f| %&gt;
    &lt;%= f.radio_button :approve, 'Approved' %&gt; 
      &lt;%= f.label :approve, 'Approve Request', :value =&gt; 'Approved' %&gt; &amp;nbsp &amp;nbsp
      &lt;%= f.radio_button :approve, 'Denied' %&gt;
      &lt;%= f.label :approve, 'Deny Request', :value =&gt; 'Denied' %&gt;&amp;nbsp &amp;nbsp
       &lt;%= f.radio_button :approve, 'Unapproved' %&gt;
      &lt;%= f.label :approve, 'Keep Request Unapproved', :value =&gt; 'Unapproved' %&gt;&lt;br&gt;&lt;br&gt;
    &lt;%= f.submit "Submit" %&gt;&lt;br&gt;
   &lt;% end %&gt;&lt;% end %&gt;
  
    &lt;%= link_to 'Back', articles_path %&gt;
    &lt;/center&gt;&lt;/body&gt;
  </code></pre>
  
  <p>app\models\user.rb</p>
  
  <pre><code>  class User &lt; ActiveRecord::Base
  
      # Include default devise modules. Others available are:
      # :confirmable, :lockable, :timeoutable and :omniauthable
      devise :database_authenticatable, :registerable,
             :recoverable, :rememberable, :trackable, :validatable, :omniauthable
  
     def self.generate_random_password
          Digest::SHA1.hexdigest(Time.now.to_s)
      end 
  
      def create
          User.create(user_params)
      end  
      private 
      def user_params
          params.require(:user).permit(:firstname, :lastname, :displayname, :username, :email,       :password, :password_confirmation, :remember_me)
      end
    end
  </code></pre>
  
  <p>app\controllers\articles_controllers.rb</p>
  
  <pre><code>  class ArticlesController &lt; ApplicationController
    def new
      @article = Article.new
    end
  
    def show  
      @article = Article.find(params[:id])
      end
  
    def create 
       @article = Article.new(article_params)
  
      respond_to do |format|
       if  @article.save
              FormMailer.confirmation_email(@article).deliver
              AdminMailer.confirmation_email(@article).deliver
              format.html { redirect_to @article, notice: 'successful' }
              format.json { render :show, status: :created, location: @article }
          #redirect_to @article
        else 
          format.html { render :new }
          format.json { render json: @article.errors, status: :unprocessable_entity }
          #render 'new'
      end
     end
    end 
  
    helper_method :is_admin?
    def is_admin?
        notsure == 'john_smith'
       end
  
    def index  
      @articles = Article.all 
    end
  
    def edit 
      @article = Article.find(params[:id])
      end
  
    def update
      @article = Article.find(params[:id])
  
      if @article.update(art_param)
          redirect_to root_path
      end
    end
  
    private 
    def article_params    
          params.require(:article).permit(:name, :email, :phone_number, :dept_name, :doc,             :inquiry, :dob, :info, :time)
    end
  
    def art_param
      params.require(:article).permit(:approve)
    end
  
    end
  </code></pre>
  
  <p>app\views\devise\sessions\new.html.erb</p>
  
  <pre><code>  &lt;center&gt;&lt;h2&gt;Request Form - Sign In&lt;/h2&gt;
    &lt;% if user_signed_in? %&gt;
        Welcome &lt;%= current_user.email %&gt; (&lt;%= link_to "logout", destroy_user_session_path,              :method =&gt; :delete %&gt;)
    &lt;% else %&gt;
        You are currently not logged in,  &lt;%= link_to "Log In Here",       user_omniauth_authorize_path(:ldap) %&gt;
    &lt;% end %&gt;
  
    &lt;!-- &lt;%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %&gt;
      &lt;div&gt;&lt;%= f.label :username %&gt;&lt;br /&gt;
      &lt;%= f.text_field :username, autofocus: true %&gt;&lt;/div&gt;
  
      &lt;div&gt;&lt;%= f.label :password %&gt;&lt;br /&gt;
        &lt;%= f.password_field :password, autocomplete: "off" %&gt;&lt;/div&gt;
  
      &lt;% if devise_mapping.rememberable? -%&gt;
        &lt;div&gt;&lt;%= f.check_box :remember_me %&gt; &lt;%= f.label :remember_me %&gt;&lt;/div&gt;
      &lt;% end -%&gt;
  
      &lt;div&gt;&lt;%= f.submit "Sign in" %&gt;&lt;/div&gt;
    &lt;% end %&gt; 
  
    &lt;%= render "devise/shared/links" %&gt;--&gt;
    &lt;/center&gt;
  </code></pre>