Created
July 14, 2015 20:31
-
-
Save afbroman/2fb94722c9f0a4e5ab06 to your computer and use it in GitHub Desktop.
Reform multiparameter date issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= simple_form_for @form do |f| %> | |
<%= f.input :username %> | |
<%= f.input :birthdate, as: :date %> | |
<%= f.button :submit %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserForm < Reform::Form | |
include ModelReflections | |
property :username | |
property :birthdate, multi_params: true, type: Date | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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