Reputation: 157
I'm trying to create a post model that has a text associated with it as the post. However, as I want to use it as a blog, I want to convert the text into html, like if my input text has blah I want it to display a large header.
This is my input form for the Post model so far:
<p>
<%= f.label :Title %><br>
<%= f.text_field :Title %>
</p>
<p>
<%= f.label :Post %><br>
<%= f.text_area :Post %>
</p>
So when I write a post, and use hello it shows up as that instead of html.
And this is my Post model
class Post < ActiveRecord::Base
attr_accessible :Post, :Title
has_many :comments, dependent: :destroy
validates :title, presence: true, length: { minimum: 5 }
end
Upvotes: 2
Views: 1169
Reputation: 121
Are you able to save posts into database? If yes then write below code
index method in your post controller
def index
posts = Post.all
end
index.html.erb
<%= @posts.each do |f| %>
<%= f.Title %>
<%= f.Post %>
<%end%>
Hope I answered what you were looking for.
Upvotes: 0