Q: Using hidden fields in rails views What is the best practice using hidden fields in html views?
In my html.erb I need to check if a value exists,  if it does then u want to ensure a button remains disabled.
Can I set a hidden field in ruby code like this ;
<% if @is_draft %>
<input type="hidden" id="isdraft "value="true"><% end %>

Then can I access this in my jquery code? 
Is this accepted practice? Note that the javascript is in its own file,  the script is not in the html.erb file 

A: It is regarded as pretty poor practice most of the time.
Instead it is usually better to render the button as disabled on the server side after checking the condition.
Also make sure to sanitize the requests made by this form (button is clicked although your condition does not permit it). Users could un-disable the button and click it.
If you find that you have to save some information in HTML for whatever reason, I would resort to data-*-attributes!
Hope that helps!
EDIT pseudocode example:
# MyView.html.erb
<% unless @is_draft %>
   <%= render partial: 'my_checkbox_button_enabling', format: [:js] %>
<% end %>

<%= button_tag "My nice button", disabled: true, id: "my-button" %>

