First of all you can't place id on inputs, because you will end up with two inputs with same and jQuery will only find the first one. Secondly, you need to use $(this) inside your handler.
You need sth in line:
<%= f.input :ration_card ,as: :radio_buttons,collection: ["Yes","No"], wrapper_html: {id: "rationcard"} %>
<%= f.input :rationcardNum , label: "Ration Card No." ,wrapper_html: {id: "rationcard_no"} %>
$(function(){
var toggle_rationcardNum = function(visible) {
if (visible){
$("#rationcard_no").show();
} else {
$("#rationcard_no").hide();
}
}
$("#rationcard input").change(function(){
toggle_rationcardNum($(this).val()=="Yes")
})
toggle_rationcardNum($("#rationcard input:checked").val()=="Yes")
})();