Pregunta

I started rails a week ago, I want to know that how to display an unmodifiable text using erb file, <%= f.label :email %> <%= f.text_field :email %> Here, instead of a text-box, I need a simple text displaying email id.

Any clues?

¿Fue útil?

Solución

By "unmodifiable text" in a text field, I'm assuming you don't just want to have the email displayed on screen (if so, then Yuri Barbashov is correct) but also want it inside an input text field, but be unmodifiable.

In that case, you might be best off using javascript. Have a look at this StackOverflow answer for some JQuery examples.

Edit:

Actually, the solution here may be easier if you never plan on re-enabling the text field:

<%= f.text_field :email, disabled: true %>

Otros consejos

<%= @your_model.email %>

But to be more precise you have to show your view code

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top