Sha256: f0738e987deae8a256d04ec5273687e743579c87e29999d5d3afd22361e34b74

Contents?: true

Size: 638 Bytes

Versions: 8

Compression:

Stored size: 638 Bytes

Contents

class PrintsController < ApplicationController
  respond_to :html, :json, :xml, :js
  before_filter :add_user
  
  def create
   @print = parent.prints.create(params[:print]||{})
   
   respond_with(@print, :location => send("#{parent.class.name.underscore}_url",parent))
  end
  
  protected
  def parent
    @parent ||= params[:printable_type].classify.constantize.find(params[:printable_id])
    instance_variable_set("@#{params[:printable_type].underscore}",@parent)
  end
  
  def add_user
    if defined?(current_user) && current_user
      params[:print] ||= {}
      params[:print][:user_id] = current_user.id
    end
  end
  
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
how_are_we_doing-0.0.9 app/controllers/prints_controller.rb
how_are_we_doing-0.0.8 app/controllers/prints_controller.rb
how_are_we_doing-0.0.7 app/controllers/prints_controller.rb
how_are_we_doing-0.0.6 app/controllers/prints_controller.rb
how_are_we_doing-0.0.5 app/controllers/prints_controller.rb
how_are_we_doing-0.0.4 app/controllers/prints_controller.rb
how_are_we_doing-0.0.3 app/controllers/prints_controller.rb
how_are_we_doing-0.0.2 app/controllers/prints_controller.rb