문제

What I'm trying to do is email someone a link where they can reply to a message, but obscuring the message_id with a token so that people can't just spam replies to any messages they like.

What I want is a path something like: /reply/:message_reply_token/new

That will generate the correct form with the previous message visible for the user to reply to using something like this:

@parent_message = Message.find_by_reply_token(params[:message_reply_token])
@reply_message = @parent_message.reply_messages.build

The problem I'm having is in my create action. How do I get that :message_reply_token back to the create action to actually create and save the new reply?

도움이 되었습니까?

해결책

You could put it in hidden field in form:

<%= hidden_field_tag :message_reply_token, params[:message_reply_token] %>

and use it in create action via:

params[:message_reply_token]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top