For my Rails app, we developed an half home-brewed email system. We created a model called Email which then gets added to a queue to be sent (using a web service).
To create templates, we've been just mashing strings together in the model, ie:
Email < ActiveRecord::Base
def self.stock_message(recipient)
email = Email.create do |e|
e.recipient = recipient
e.message = String.new
e.message << "first line <br />"
e.message << "second line <br />"
end
end
end
#to send:
e = Email.stock_message "[email protected]"
This clearly violates MVC and really becomes a problem when I want to format strings using helper methods. How can I properly separate the view code from the model?