Sha256: a857336faa4217cde6cf2c190764ef52060a08e301fa8b826b0e86b1b88e32f0

Contents?: true

Size: 630 Bytes

Versions: 8

Compression:

Stored size: 630 Bytes

Contents

class ViewsController < ApplicationController
  respond_to :html, :json, :xml, :js
  before_filter :add_user
  
  def create
   @view = parent.views.create((params[:view]||{}))
   
   respond_with(@view, :location => send("#{parent.class.name.underscore}_url",parent))
  end
  
  protected
  def parent
    @parent ||= params[:viewable_type].classify.constantize.find(params[:viewable_id])
    instance_variable_set("@#{params[:viewable_type].underscore}",@parent)
  end
  
  def add_user
    if defined?(current_user) && current_user
      params[:view] ||= {}
      params[:view][: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/views_controller.rb
how_are_we_doing-0.0.8 app/controllers/views_controller.rb
how_are_we_doing-0.0.7 app/controllers/views_controller.rb
how_are_we_doing-0.0.6 app/controllers/views_controller.rb
how_are_we_doing-0.0.5 app/controllers/views_controller.rb
how_are_we_doing-0.0.4 app/controllers/views_controller.rb
how_are_we_doing-0.0.3 app/controllers/views_controller.rb
how_are_we_doing-0.0.2 app/controllers/views_controller.rb