Skip to content

Instantly share code, notes, and snippets.

@afbroman
Created July 14, 2015 20:31
Show Gist options
  • Save afbroman/2fb94722c9f0a4e5ab06 to your computer and use it in GitHub Desktop.
Save afbroman/2fb94722c9f0a4e5ab06 to your computer and use it in GitHub Desktop.
Reform multiparameter date issue
<%= simple_form_for @form do |f| %>
<%= f.input :username %>
<%= f.input :birthdate, as: :date %>
<%= f.button :submit %>
<% end %>
class User < ActiveRecord::Base
end
class UserForm < Reform::Form
include ModelReflections
property :username
property :birthdate, multi_params: true, type: Date
end
class UsersController < ApplicationController
def new
@form = UserForm.new(User.new)
end
def create
@form = UserForm.new(User.new)
if @form.validate(params[:user])
@form.save
end
redirect_to @form.model
end
def show
@user = User.find(params[:id])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment