title: Rails 4 Simple Form Validations
body: <p>For some reason my validations aren't working correctly.  I can submit the form if it's blank, and it gets processed by the controller.  Isn't the point of the model to validate the params before it goes to the controller?</p>
  
  <p>My Controller is:</p>
  
  <pre><code>class SubscribersController &lt; ApplicationController
    before_action :set_subscriber, only: [:show, :edit, :update]
  
    # GET /subscribers
    # GET /subscribers.json
    def index
      @subscribers = Subscriber.all
    end
  
    # GET /subscribers/1
    # GET /subscribers/1.json
    def show
      # This is Wrong, but You Get The Idea
      @subscriber = Subscriber.find_by(params[:id])
    end
  
    # GET /subscribers/new
    def new
      @subscriber = Subscriber.new
    end
  
    # GET /subscribers/1/edit
    def edit
    end
  
    # POST /subscribers
    # POST /subscribers.json
      def create
        @subscriber = Subscriber.new(subscriber_params)
        respond_to do |format|
          if @subscriber.save
            format.html { redirect_to :back, notice: 'Thanks For Joining Our Mailing List!' }
            format.json { render :back, status: :created, location: @subscriber }
          else
            format.html { redirect_to :back, notice: 'Error, Invalid Entry, or you are on the List Already!'}
            format.json { redirect_to :back, @subscriber.errors, status: :unprocessable_entity }
          end
        end
      end
  
      # PATCH/PUT /subscribers/1
      # PATCH/PUT /subscribers/1.json
      def update
        respond_to do |format|
          if @subscriber.update(subscriber_params)
            format.html { redirect_to :back, notice: 'Subscriber was successfully updated.' }
            format.json { redirect_to :back, status: :ok }
          else
            format.html { redirect_to :back }
            format.json { render json: @subscriber.errors, status: :unprocessable_entity }
          end
        end
      end
  
      # DELETE /subscribers/1
      # DELETE /subscribers/1.json
      def destroy
        if @subscriber = Subscriber.find_by(params[:email])
        respond_to do |format|
            if @subscriber.destroy
            format.html { redirect_to :back, notice: 'Subscriber was successfully destroyed.' }
            format.json { head :no_content }
            else
              format.html { redirect_to :back, notice: 'Something Wrong' }
              format.json { render json: @subscriber.errors, status: :unprocessable_entity }
            end
        end
        else
          redirect_to :back
          flash[:error] = "Couldn't Find That Email Database!"
        end
      end
  
    private
      # Use callbacks to share common setup or constraints between actions.
      def set_subscriber
        @subscriber = Subscriber.find(params[:id])
      end
  
      # Never trust parameters from the scary internet, only allow the white list through.
      def subscriber_params
        params.require(:subscriber).permit(:name, :email)
      end
  end
  </code></pre>
  
  <p>and my model is:</p>
  
  <pre><code>class Subscriber &lt; ActiveRecord::Base
      before_validation :downcase_email
  
      validates_uniqueness_of :email
      validates_format_of :email,:with =&gt; Devise::email_regexp
      validates_presence_of :name, :message =&gt; "Name can't be blank"
      validates_presence_of :email, :message =&gt; "Need an Email!!", on: :destroy
  
  
      private
      def downcase_email
        self.email = self.email.downcase if self.email.present?
      end
  end
  </code></pre>
  
  <p>lastly my form:</p>
  
  <pre><code>&lt;div class="five wide column subscriber"&gt;
    &lt;div class="ui inverted form segment"&gt;
      &lt;%= simple_form_for(@subscriber) do |f| %&gt;
      &lt;%= f.error_notification %&gt;
      &lt;h3 class="ui header"&gt;Join Our Mailing List&lt;/h3&gt;
      &lt;div class="two fields"&gt;
        &lt;div class="field"&gt;
          &lt;%= f.input :name, placeholder: "Enter Name", required: true, error_html: { id: 'password_error'}%&gt;
        &lt;/div&gt;
        &lt;div class="field"&gt;
          &lt;%= f.input :email, placeholder: "Enter Email", type: "email", required: true%&gt;
        &lt;/div&gt;
      &lt;/div&gt;
        &lt;%= f.submit "Join", class: "ui blue submit button" %&gt;
      &lt;% end %&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Let me know if I need to supply any more information.  I hope this is an easy fix, but I'm not sure what I'm doing wrong.</p>