Sha256: 0d3107d4e2680e3fe00c2a8d8565a85ba2cc7e243bf5b63451493dff7bf74068
Contents?: true
Size: 929 Bytes
Versions: 1
Compression:
Stored size: 929 Bytes
Contents
class Transit::PostsController < TransitController defaults collection_name: 'posts', instance_name: 'post' respond_to :html, :js, :json def collection @posts ||= end_of_association_chain.page((params[:page] || 1), per: 20) end def create @post = resource_class.new(params[:post]) set_resource_ivar(@post) unless @post.save render action: 'new', error: 'Oops, looks like you forgot something!' and return end redirect_to transit.edit_polymorphic_path(resource), success: 'Your post was created!' end def update @post = Post.find(params[:id]) unless @post.update_attributes(params[:post]) render action: :edit, error: 'Looks like you forgot a couple fields' and return end redirect_to transit.edit_polymorphic_path(@post), success: 'Your post was updated.' end def destroy destroy!(success: 'The selected post has been deleted.') end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
transit-0.0.2 | app/controllers/transit/posts_controller.rb |