I have a drop-down that users can choose what template they are about to receive. I'm pretty novice to Rails but I kind of go the logic Front-end = JavaScript and that's what I did, but this use of JavaScript seems like Rails should be able to handles it.
<div class="form-group">
<%= form_tag %>
<%= select_tag :statement_type, options_for_select(Statement.statement_types.keys.to_a), :class => 'id_select', :id => 'secret_id' %>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<%= link_to "New Form", new_statement_template_path(:statement_type => 'SoW'), :id => "secret_submit", method: :post %>
</div>
The -only- purpose of the form_tag is because I couldn't get the link_to to successfully launch other-wise.
I make the link dynamic by using this function
$('#secret_id').on('change', function(){
$('#secret_submit').attr('href', '/statements/new/statement_type='+ $('#secret_id').val());
});
I of course now have a pretty ugly URL, and in addition had to create a custom route, so I am wondering about the 'Rails Way' of doing this. Or at the least, making the URL prettier.