我需要从另一个操作访问控制器级别操作。这可以通过视图访问(因此需要真实性令牌)
def post_message
#creates the message
#normally accessed via webform with authenticity token
end
def post_via_email
#my virtual mailserver calls this method when it receives an email
#i need to call the post_message function
end
我知道如果我用post_message()调用前者,那将是一个GET调用。没有真实性令牌。
如果我从网页上访问它以及params和令牌,我如何调用前一个函数?
答案 0 :(得分:1)
我不认为您可以直接从post_via_email操作调用post_message。
你可以尝试一下。
def post_message
private_post_message(params)
#creates the message
#normally accessed via webform with authenticity token
end
def post_via_email
private_post_message(params)
#my virtual mailserver calls this method when it receives an email
#i need to call the post_message function
end
private
def private_post_message(param)
#posting message code here
end