سؤال

I'm trying to render html in my Rails application, but the html shows as plain text.

Here is my edit.erb file:

<form action="/posts/update">
  <input type="hidden" name="id" value="<%= post.id %>"/>
  <input type="text" name="post[title]" value="<%= post.title %>"/>
  <textarea rows="10" cols="30" name="post[body]" id=""><%= post.body %></textarea>
  <button type="submit">Update</button>
</form>

enter image description here

I use RubyMine as IDE.

هل كانت مفيدة؟

المحلول

Change the filename to edit.html.erb.

With only erb Rails doesn't know you are tyring to render html and will render it as text.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top