I have a standard rails observer configured:
class TipObserver < ActionController::Caching::Sweeper
observe Tip
def after_save(tip)
profile_link = link_to tip.profile.name, profile_path(tip.profile)
Profile.followers(tip.quality).each{|profile|
message = Message.new
message.sender = Profile.first
message.recipient = profile
message.subject = "New Tip #{tip.name}"
tip_link = link_to tip.name, tip_path(tip)
message.body = "Hey #{profile.name}\n Here is a tip for you..#{tip_link} from #{profile_link}"
message.save!
}
end
end
Yes I know this is set up as a Sweeper - its basically the same as an Observer buthas access to the link_to method, however it doesn't seem to have the routes configured. profile_path and tip_path methods are nil.
Perhaps there is another way to achieve this? Perhaps a more "Rails Way"?
It would be really nice if there was a way to create the message with a view template for the message.body.
Any suggestions?