 	data = req.body
 	req.rule.createSensorRule data, (err, sensorRule) ->
 		if err
-			res.send error: "Server error while creating SensorRule.", 500
+			res.send error: err, 500
 		else
 			res.send sensorRule, 201
 

	data = req.body
	Rule.create data, (err, rule) ->
		if err?
			res.send error: "Server error while creating rule.", 500
		else
			res.send rule, 201


	data = req.body
	req.rule.createActuatorRule data, (err, actuatorRule) ->
		if err
			res.send error: err, 500
		else
			res.send actuatorRule, 201

module.exports.update = (req, res) ->
	data = req.body
	req.rule.updateAttributes data, (err, rule) ->
		console.log("RULE UPDATE - rule: " + rule)
		if err
			res.send error: err, 500
		else
			res.send rule, 200

module.exports.delete = (req, res) ->
	req.rule.destroy (err) ->
		if err
			res.send error: err, 500
		else
			res.send success: true, 200
