0

I am pretty new to Ruby on rails world. I was mainly ASP.net web developer but now I am learning RoR. In my view I have a datetime picker, which includes an <%text_field> tag which holds the selected datetime by the user. I have two of these <%text_field> tags, one for start date and one for end date. There is also a tag in my page that redirects this page to another one. I want to send start and end date as query string while clicking on this link. I have already found the below solution:

<%= text_field :datepick8, :title, :class=> "form-control" %> 
.
.
.
<% path = "page1.csv?"   
  path << "&startdate=\"+$(\"#datepick8_title\").val()"
   %>
<%= link_to "Page2", "", onclick: "window.location = \"#{path}" %>

This works fine, but as long as end date is not added. When I add end date to path then it does not work. It seems when anything comes after .val() then it fails to redirect.

So, I want to solve my problem whether by fixing the above solution or a complete new idea. Thank you in advance for the helps.

EDIT:

Let me put it this way, is there any simple way to pass a textbox's value to controller? In ASP.net one can simply add runat="server" to any component and access its value in server side. Is there any method like that in rails?

Ehsan Enayati
  • 299
  • 2
  • 16

0 Answers0