开发者

Keeping URL parameters after form submit

开发者 https://www.devze.com 2023-04-06 06:45 出处:网络
I am building a questionnaire app, where before the questionnaire begins, the interviewer will first ask to check the interviewee\'s details, and update them if necessary. To do this, the app switches

I am building a questionnaire app, where before the questionnaire begins, the interviewer will first ask to check the interviewee's details, and update them if necessary. To do this, the app switches from the questionnaire controller to the edit form on the member controller. When this is done, it then needs to go back to the questionnaire controller to begin the questions. Because this app works with different questionnaires, the 'questionnaire' and 'memberid' parameter must stay in the url at all times. However, when I submit the form after editing details, these parameters are lost from the url, the start link will not work without them.

I have read that hidden_field_tags should be used, however I am struggling to get them to work...

<%= hidden_field_tag "questionnaire", params[:questionnaire] %>
<%= hidden_field_tag "memberid", params[:memberid] %>

I am also a lit开发者_如何学运维tle unsure what I must put in the controller for this to work. Any help is much appreciated, thank you!


If you're using link_to helper, then you should be able to pass parameters like this:

link_to "link title", some_path(:questionnaire => "that other one", :memberid => 9)

Of course, you've to include extra parameters when you're doing redirects as well.

Also you may consider storing information in a session. Here is some basic overview: http://www.tutorialspoint.com/ruby-on-rails/rails-session-cookies.htm

0

精彩评论

暂无评论...
验证码 换一张
取 消