Skip to content

Instantly share code, notes, and snippets.

@ka8725
Created September 5, 2014 13:58
Show Gist options
  • Save ka8725/34bc4d5e81bf56956bd9 to your computer and use it in GitHub Desktop.
Save ka8725/34bc4d5e81bf56956bd9 to your computer and use it in GitHub Desktop.
class CreateUserForm
include ActiveModel::Model
attr_accessor :email
attr_accessor :name
def initialize
@user = User.new
end
def attributes=(attrs)
@user.email = attrs[:email]
@email = attrs[:email]
@user.name = attrs[:name]
@name = attrs[:name]
end
def save
valid? && @user.save
end
end
@avsej
Copy link

avsej commented Sep 5, 2014

    @user.email = @email = attrs[:email]
    @user.name = @name = attrs[:name]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment