原题来自 ruby on rails tutorial 中的 message extention: Messaging Twitter supports direct (private) messaging by prefixing a micropost with the letter“d”. Implement this feature for the sample application. The solution will probably involve a Message model and a regular expression match on new microposts.
也就是说 要在 micropost controller 中调用 message controller 中的 create:
micropostcontroller
def create
@micropost =current_user.microposts.build(params[:micropost])
if 首字母为d
**用micropost创建message**
else
正常创建@micropost
end
我查了一下,不知道是不是这样写:? message = Message.create(@micropost)