models: remove belongs_to_creator macro.
The belongs_to_creator macro was used to initialize the creator_id field to the CurrentUser. This made tests complicated because it meant you had to create and set the current user every time you wanted to create an object, when lead to the current user being set over and over again. It also meant you had to constantly be aware of what the CurrentUser was in many different contexts, which was often confusing. Setting creators explicitly simplifies everything greatly.
This commit is contained in:
@@ -43,7 +43,7 @@ class PoolsController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
@pool = Pool.create(pool_params)
|
||||
@pool = Pool.create(pool_params.merge(creator: CurrentUser.user))
|
||||
flash[:notice] = @pool.valid? ? "Pool created" : @pool.errors.full_messages.join("; ")
|
||||
respond_with(@pool)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user