mysql - Bring value from one webpage to another webpage in Ruby on Rails website without database -


summary

i'm trying bring value 1 webpage webpage on ruby on rails site without saving second time mysql database. i'm new ruby, in advance patience.

overview

my website users can save map have created. now, want them able edit maps.

i have webpage, newmaps.html.erb, renders map. map has unique id:

    <%= newsavedmap.id %> 

there's "edit" button under map. when user clicks "edit", want him taken webpage, maptry.html.erb , form lets user edit map.

problem

i want specific newsavedmap.id transfer on maptry.html.erb can load form newsavedmap.startingaddress, newsavedmap.endingaddress, , of other data associated record.

i think i'm supposed use "post", i'm not sure how in situation. link has given me ideas, form not rails form i'm not sure how translate own solution: pass custom _form text field parameter second page rails

maptry.html.erb

    <div id="control_panel">     <div>     <input id="startingaddress" type="text" name="starthere" size="56"></p>     </div>     <div>     <input id="endingaddress" type="text" name="endhere" size="56"></p>     </div>     <div>             <input onclick="calcroute();" id="showmapview" value="show map">     </div>        </div> 

ok, after night of research, able pull few different sources helped me answer one. helpful answers here: pass parameter link_to ruby on rails , pass variable between views in rails

i learned how use link_to pass parameters 1 view view (one webpage another, user). here how did it:

newmaps.html.erb

    <%= link_to 'edit', maptry_path(:newsavedmap_id => newsavedmap.id) %> 

the above code uses anchor text "edit" , links user maptry.html.erb view. brings on newsavedmap_id. then, updated maptry_controller

maptry_controller.rb

    @newsavedmap = newsavedmap.find(params[:newsavedmap_id]) 

with in place, can add of information map want inserting @newsavedmap.whatever. see below. added params[:newsavedmap_id] in hidden field in case necessary.

maptry.html.erb

    <input name="newsavedmapid" type="hidden" value="<%= params[:newsavedmap_id] %>" />       <input id="start" type="text" name="starthere" size="56" value="<%= @newsavedmap.start%>"></p> 

likely, isn't best or solution out there, said, i'm new rails. appreciate other answers people have can continue learn. thanks!


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -