Created
June 27, 2012 15:25
-
-
Save felipemesquita/3004819 to your computer and use it in GitHub Desktop.
This file contains 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 AppResponder < ActionController::Responder | |
include Responders::HttpCacheResponder | |
include Responders::CollectionResponder | |
end |
This file contains 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 ScatterPlotsController < ApplicationController | |
before_filter :parent | |
before_filter :build_resource, :only => [:new, :create] | |
before_filter :find_resource, :only => [:edit, :update, :show, :destroy] | |
before_filter :collection, :only => [:index] | |
def index | |
respond_with(collection) | |
end | |
def new | |
respond_with(resource) | |
end | |
def create | |
resource.save | |
respond_with(parent, resource) | |
end | |
def show | |
respond_with(resource) | |
end | |
def update | |
resource.update_attributes(params[:scatter_plot]) | |
respond_with(parent, resource) | |
end | |
def destroy | |
resource.destroy | |
respond_with(parent, resource) | |
end | |
protected | |
def find_parent | |
@survey = current_organization.surveys.find(params[:survey_id]) | |
end | |
def parent | |
@survey ||= find_parent | |
end | |
def find_resource | |
@scatter_plot = parent.scatter_plots.find(params[:id]) | |
end | |
def build_resource | |
@scatter_plot = parent.scatter_plots.new(params[:scatter_plot]) | |
end | |
def resource | |
@scatter_plot ||= find_resource | |
end | |
def collection | |
@scatter_plots ||= parent.scatter_plots | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment