I'm hoping someone can enlighten a noob as to the 'Rails Way' of redirecting to a specific survey using the Surveyor gem (1.4.0pre). I've created a separate 'Members' model to capture an email address on landing, and when Submit/Next is clicked, I'd like that email address persisted to the db and the desired survey shown.
MembersController:
def create
@member = Member.new(member_params)
if @member.save
flash[:success] = "Thanks for taking part!"
# This should redirect to the new survey.....
else
render 'new'
end
end
I've read the gem documentation and it states a POST request to surveys/name-of-survey/
is required, but I understand redirect_to
issues a GET request and calling a method of one controller (surveys) from within another controller (members) is bad news and not advised.
Any assistance on how to implement the desired behaviour would be greatly appreciated!
Thanks.
POST should only be needed when the user sends data. Using redirect_to here seems sensible, since you will then just prepare a new page, just in a new request.