Created
November 11, 2012 17:48
-
-
Save haldun/4055668 to your computer and use it in GitHub Desktop.
decent exposure with sti
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PostsController < ApplicationController | |
respond_to :html, :json | |
expose(:posts) { post_type.scoped } | |
expose(:post_type) { params[:type].constantize } | |
expose(:post) do | |
if id = params[:id] | |
posts.find id | |
else | |
post_type.new params[post_type.name.downcase.to_sym] | |
end | |
end | |
def index | |
respond_with posts | |
end | |
def new | |
end | |
def edit | |
end | |
def show | |
respond_with post | |
end | |
def create | |
if post.save | |
end | |
respond_with post | |
end | |
def update | |
if post.save | |
end | |
respond_with post | |
end | |
def destroy | |
post.destroy | |
respond_with post | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resources :texts, controller: 'posts', type: 'Text' | |
resources :rsses, controller: 'posts', type: 'Rss' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment