Skip to content

Commit

Permalink
add back user to the content object
Browse files Browse the repository at this point in the history
  • Loading branch information
zr2d2 committed Apr 29, 2012
1 parent 1bc5457 commit 6d708a3
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions app/controllers/contents_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class ContentsController < ApplicationController
before_filter :get_content_const, :only => [:new, :create]
load_and_authorize_resource :except => [:index, :show]

# Grab the constent object for the type of
# content we're working with. Probably needs
# additional error checking.
Expand Down Expand Up @@ -41,22 +41,22 @@ def show
# GET /contents/new
# GET /contents/new.xml
# Instantiate a new object of params[:type].
# If the object isn't valid (FooBar) or isn't a
# If the object isn't valid (FooBar) or isn't a
# child of Content (Feed) a 400 error is thrown.
def new
#The default content type is defined in the Configuration model as default_upload_type
if params[:type].nil? && ConcertoConfig[:default_upload_type] != false
@content_const = ConcertoConfig[:default_upload_type].camelize.constantize
end

#We don't recognize the content type, or
#its not a child of Content.
if @content_const.nil? || @content_const.superclass != Content
render :nothing => true, :status => 400
else

@content = @content_const.new()

respond_to do |format|
format.html { } # new.html.erb
format.xml { render :xml => @content }
Expand All @@ -74,10 +74,12 @@ def edit
# POST /contents.xml
def create
@content = @content_const.new(params[@content_const.model_name.singular])
@content.user = current_user

@feed_ids = []
if params.has_key?("feed_id")
@feed_ids = params[:feed_id].values
end
end

respond_to do |format|
if @content.save
Expand Down Expand Up @@ -123,7 +125,7 @@ def update
def destroy
@content = Content.find(params[:id])
authorize! :delete, @content

@content.destroy

respond_to do |format|
Expand Down

0 comments on commit 6d708a3

Please sign in to comment.