Skip to content

Commit

Permalink
Associated screen with new subscription object to make CanCan work fo…
Browse files Browse the repository at this point in the history
…r subscriptions#manage
  • Loading branch information
augustf committed Dec 18, 2012
1 parent 45fe912 commit 79507bf
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/controllers/subscriptions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ def index

# GET /screen/:screen_id/subscriptions/manage
def manage
@subscription = Subscription.new
#stub out the screen ID so that CanCan can find an owner to auth
@subscription.screen_id = @screen.id
auth!

@this_field = Field.find(params[:field_id])
@fields = @screen.template.positions.collect{|p| p.field}
@subscription = Subscription.new


respond_to do |format|
format.html # manage.html.erb
end
Expand Down Expand Up @@ -124,6 +128,9 @@ def save_all
@weights = params[:subscription_weight].values
end

#Do some fun auth stuff before we actually do anything dangerous
auth!

#Get a hold of all the subscriptions ID's that aren't in the form and destroy them (as the user deleted them in the form)
@all_screen_subs = @screen.subscriptions.where(:field_id => @field.id).map(&:id)
#Use the subtraction operator to get the difference between the arrays
Expand Down Expand Up @@ -152,9 +159,6 @@ def save_all
@this_subscription = Subscription.new
end

#Do some fun auth stuff before we actually do anything dangerous
auth!

#Update attributes of all subscriptions present in form and populate array with any errors encountered
@errnos[i] = !@this_subscription.update_attributes(:screen => @screen, :field => @field, :feed_id => feed_id, :weight => @weights[i])
end
Expand Down

0 comments on commit 79507bf

Please sign in to comment.