I'll start by saying that I'm new to rails. This question is for a class I'm currently taking. The lesson topic is CRUD, and the content is a db that stores posts along with their titles and comments.
The instructions are as follows:
Overwrite the title of every fifth instance of Post with the text "CENSORED".
This is my controller:
class PostsController < ApplicationController
def index
@posts = Post.all
end
def show
end
def new
end
def edit
end
end
This is my view file:
<h1>All Posts</h1>
<% @posts.each do |post| %>
<div class="media">
<div class="media-body">
<h4 class="media-heading">
<%= link_to post.title, post %>
</h4>
</div>
</div>
<% end %>
This is my model:
class Post < ActiveRecord::Base
has_many :comments
end
I'm not really sure where to even start and would really appreciate any help at all. A point in the right direction would be great. Thanks.