app/controllers/transit/contexts_controller.rb in transit-0.0.1 vs app/controllers/transit/contexts_controller.rb in transit-0.0.2

- old
+ new

@@ -1,20 +1,23 @@ -class Transit::ContextsController < Transit::TransitController - include Transit::Helpers::ControllerHelpers - unloadable +class Transit::ContextsController < TransitController + respond_to :js + belongs_to :post, :page, polymorphic: true + actions :new, :destroy def new - @package = scope_class.find(params["#{scope_name}"]) - @context = params[:type].classify.constantize.new + ptype = symbols_for_association_chain.first.to_s + parent_obj = ptype.classify.constantize.find(params["#{ptype}_id"]) + set_resource_ivar(parent_obj) + @context = parent_obj.contexts.build({}, params[:type].classify.constantize) respond_with(@context) end + def destroy - @package = scope_class.find(params["#{scope_name}"]) - @context = scope_class.find(params[:id]) - @field.destroy + parent.contexts.find(params[:id]) + @context.destroy flash[:success] = "The selected field has been removed." - respond_with(@field) + respond_with(@context) end end \ No newline at end of file