ruby-x.github.io/app/controllers/blog_controller.rb

20 lines
382 B
Ruby
Raw Normal View History

2018-04-10 18:11:33 +02:00
class BlogController < ApplicationController
def index
2018-04-10 21:14:02 +02:00
@posts = Post.posts
2018-04-10 18:11:33 +02:00
end
2018-04-10 21:14:02 +02:00
def post
2018-04-10 18:11:33 +02:00
title = params[:title]
return redirect_to(root_path) unless title
2018-04-10 21:14:02 +02:00
@post = get_post(title)
return redirect_to(root_path) unless @post
2018-04-10 18:11:33 +02:00
end
2018-04-10 21:14:02 +02:00
def get_post(title)
post = Post.posts[title]
#puts "No #{title} in #{Post.posts.keys.join(':')}"
post
2018-04-10 18:11:33 +02:00
end
end