Sha256: 02cb4c514e381e154e84d60c123344bc5a9fad4f5fca4acf26603dcb77213bc0
Contents?: true
Size: 988 Bytes
Versions: 1
Compression:
Stored size: 988 Bytes
Contents
class ApplicationController include Dalton::Model::HasDatabase def datomic_uri App.datomic_uri end before_filter :refresh_datomic! rescue_from Dalton::NotFound do |e| render_404 "Could not find #{e.model} with id #{e.id}" end rescue_from Dalton::ValidationError do |e| render_403 "#{e.changes.model} was invalid: #{e.errors.inspect}" end end class PostsController < ApplicationController def index author = find(User).entity(params[:author]) @posts = find(Post).where(author: author) end def show @post = find(Post).entity(params[:id]) end def create author = find(User).entity(params[:author]) @post = Post.create! do |p| p.content = params[:content] p.change_ref(:author) do |a| a.last_post = p end end end def update find(Post).entity(params[:id]).change! do |p| p.content = params[:content] end end def destroy find(Post).entity(params[:id]).retract! end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dalton-0.0.1 | examples/posts_controller.rb |