app/models/jobshop/registration.rb in jobshop-0.0.29 vs app/models/jobshop/registration.rb in jobshop-0.0.37

- old
+ new

@@ -1,11 +1,17 @@ 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.singleton_class.class_eval do + validates :name, presence: true, on: :update, if: :name_changed? + end + record } def save return false unless valid? @@ -25,15 +31,15 @@ def registration_params params.fetch(:registration, ActionController::Parameters.new) end def team_params - registration_params.fetch( - :team, ActionController::Parameters.new).permit(:name) + 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) + registration_params.fetch(:user, ActionController::Parameters.new) + .permit(:email, :password, :password_confirmation) end end end