views:

24

answers:

1

Hi folks, I need to access a controller level action from another action. This is accessed by the view (so need authenticity token)

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

I know that if i call the former with post_message(), it will be a GET call. There will be no authenticity token.

How do i call the former function AS IF I am accessing it from the webpage, along with the params and token?

+1  A: 

I dont think that you can directly call post_message from post_via_email action.

You can try this out.

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
Dinesh Atoliya
thanks! that would mean some refactoring of the code, but i guess it is inevitable... =)
ming yeow