Sha256: 27a3ee57e275eab3b9c27e78ba82bd32ed05645b007a4c21105f4ca87fdd5d19
Contents?: true
Size: 952 Bytes
Versions: 9
Compression:
Stored size: 952 Bytes
Contents
module Jobshop class Registration < VirtualRecord memo_attr(:user) { team.users.build(user_params) } memo_attr(:team) { record = ::Jobshop::Team.find(params[:team_id]) record.assign_attributes(team_params) record } def save return false unless valid? result = ActiveRecord::Base.transaction do user.save! team.update!(owner: user, registration_token: nil, registration_token_sent_at: nil) end result != false end private def registration_params params.fetch(:registration, ActionController::Parameters.new) end def team_params registration_params.fetch( :team, ActionController::Parameters.new).permit(:name) end def user_params registration_params.fetch(:user, ActionController::Parameters.new). permit(:email, :password, :password_confirmation) end end end
Version data entries
9 entries across 9 versions & 1 rubygems