title: How to use date time precision gem
body: <p>I'm trying to allow a user to input a date in a very permissive format (e.g. year only, year &amp; month, or exact date). The <a href="https://github.com/Spokeo/date_time_precision" rel="nofollow">date_time_precision</a> gem seems perfect, but I'm a newbie and I can't figure out (beyond installing the gem) how to get my form to allow these various levels of precision (I've read the readme several times).</p>
  
  <p>I'm using the simple_form gem with the following in the date portion of my _form:</p>
  
  <pre><code>&lt;%= f.input :date, 
              :include_blank =&gt; true, 
              as: :string, 
              order: [ :year, :month, :day,], 
              hint: 'Order: Year, month, date' %&gt;
  </code></pre>
  
  <p>The documentation has a heading called 'Usage', and then...</p>
  
  <pre><code>require 'date_time_precision'
  </code></pre>
  
  <p>But I can't figure out where to put that. Does it go somewhere in my controller?</p>
  
  <h2>Further info:</h2>
  
  <p>I did all the usual stuff (added gem to gemfile, bundle install, restart server, and refresh form page).</p>
  
  <h2>Updates:</h2>
  
  <p>My form seems pretty much broken now, I keep getting errors like "ActionController::ActionControllerError in ArtworksController#update
  Cannot redirect to nil!"</p>
  
  <p>My routes.rb file</p>
  
  <pre><code>Rails.application.routes.draw do
    root "pages#home"
  
    get "artworks" =&gt; "artworks#index"
    # post "artworks" =&gt; "artworks#index"
  
    resources :artworks #, path: ''
  
    get "about" =&gt; "pages#about"
  end
  </code></pre>
  
  <p>My controller:</p>
  
  <pre><code>    class ArtworksController &lt; ApplicationController
    before_action :set_artwork, only: [:show, :edit, :update, :destroy]
  
    # GET /artworks
    # GET /artworks.json
    def index
      @artworks = Artwork.all
    end
  
    # GET /artworks/1
    # GET /artworks/1.json
    def show
      @artwork = Artwork.friendly.find(params[:id])
      if request.path != artwork_path(@artwork)
        redirect_to @artwork, status: :moved_permanently
      end
    end
  
    # GET /artworks/new
    def new
      @artwork = Artwork.new
    end
  
    # GET /artworks/1/edit
    def edit
    end
  
    # POST /artworks
    # POST /artworks.json
    def create
      @artwork = Artwork.new( artwork_params )
  
      respond_to do |format|
        if @artwork.save
          format.html { redirect_to @artwork, notice: 'Artwork was successfully created.' }
          format.json { render :show, status: :created, location: @artwork }
        else
          format.html { render :new }
          format.json { render json: @artwork.errors, status: :unprocessable_entity }
        end
      end
    end
  
    # PATCH/PUT /artworks/1
    # PATCH/PUT /artworks/1.json
    def update
      respond_to do |format|
        if @artwork.update(artwork_params)
          format.html { redirect_to @artworks, notice: 'Artwork was successfully updated.' }
          format.json { render :show, status: :ok, location: @artwork }
        else
          format.html { render :edit }
          format.json { render json: @artwork.errors, status: :unprocessable_entity }
        end
      end
    end
  
    # DELETE /artworks/1
    # DELETE /artworks/1.json
    def destroy
      @artwork.destroy
      respond_to do |format|
        format.html { redirect_to artworks_url, notice: 'Artwork was successfully destroyed.' }
        format.json { head :no_content }
      end
    end
  
    private
      # Use callbacks to share common setup or constraints between actions.
      def set_artwork
        @artwork = Artwork.friendly.find(params[:id])
      end
  
      # Never trust parameters from the scary internet, only allow the white list through.
      def artwork_params
        params.require(:artwork).permit(:title, :image, :genre, :category, :medium, :slug, :availability, :date, :height, :width)
      end
  end
  </code></pre>