feat(example): add example app and blog app with demos
This commit is contained in:
1 parent
28e6bc3cf2
commit
7d2312b94b
13 files changed
+234
No files matched your search
@@ -0,0 +1,24 @@
|
||||
class PostsController < Prism::Controller
|
||||
layout :application
|
||||
|
||||
def index
|
||||
render(:index, locals: { posts: Post.order(:created_at, :desc), notice: flash[:notice], errors: [] })
|
||||
end
|
||||
|
||||
def show
|
||||
render(:show, locals: { post: Post.find(params['id']) })
|
||||
rescue Prism::Orm::RecordNotFound
|
||||
halt(404, 'Post not found')
|
||||
end
|
||||
|
||||
def create
|
||||
post = Post.new(title: params['title'], body: params['body'])
|
||||
if post.save
|
||||
flash[:notice] = "Post ##{post.id} created"
|
||||
redirect url_for(:posts)
|
||||
else
|
||||
status(422)
|
||||
render(:index, locals: { posts: Post.order(:created_at, :desc), notice: nil, errors: post.errors.full_messages })
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user