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?

有帮助吗?

解决方案

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 %>

其他提示

<%= @your_model.email %>

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top