ruby-x.github.io/app/controllers/blog_controller.rb
2018-04-10 22:14:02 +03:00

20 lines
382 B
Ruby

class BlogController < ApplicationController
def index
@posts = Post.posts
end
def post
title = params[:title]
return redirect_to(root_path) unless title
@post = get_post(title)
return redirect_to(root_path) unless @post
end
def get_post(title)
post = Post.posts[title]
#puts "No #{title} in #{Post.posts.keys.join(':')}"
post
end
end