title: Ruby On Rails: make text field non-editable and display another field while editing a record
body: <p>1.How can i make a text field non-editable (readable=false) while editing record</p>
  
  <p>My Form View Code</p>
  
  <pre><code>  &lt;div class="field"&gt;
      &lt;%= f.label t :profile_name %&gt;&lt;br /&gt;
      &lt;%= f.text_field :profile_name %&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>2.How can i make a field visible while editing a record. I have a field in the database table that i just want to display to fill in while editing the record however while create a new record that field not be visible.</p>
  
  <p><strong>RESOLVED:</strong></p>
  
  <p>Never Mind Guys i got the solution,</p>
  
  <pre><code>1. 
  &lt;div class="field"&gt;
    &lt;%= f.label t :profile_name %&gt;&lt;br /&gt;
    &lt;%= f.text_field :profile_name, :readonly =&gt; f.object.persisted? %&gt;
  &lt;/div&gt;
  
  2. 
  &lt;% if f.object.persisted?%&gt;
    &lt;div class="field"&gt;
      &lt;%= f.label t :another_field %&gt;&lt;br /&gt;
      &lt;%= f.text_field :another_field%&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>