Of Models and Controllers

Johan Svensson
Wed, 17 Aug 2005 22:32:30 -0000

The IRC channel is kinda busy, so I''ll ask here instead in peace and
quiet.

My first Rails application, a system for managing raids in World of
Warcraft, is getting feature-complete. All that''s left is the logic to
assign points to participating players.

I''m not quite sure where this kind of logic goes, though. The
controller seems like the most logical place, but so far all I''ve done
in the controller is juggle data from the models to the views.

I would also like to have the actual logic for changing the player
points in the Player model instead of in the controller so I can just
call the approriate scoring method from the model, but I''m not sure
how to call it from the controller.

The method in the Player model is very simple until I can get it working:

	def give_points(target, pts)
		target.points += pts
		# No failsafe checks here yet
		target.save
	end

If I can get some pointers on how to call the methods, I can probably
figure out the rest on my own.

--
Johan Svensson