From 5ec4deb7feadd1ea4c62ea42de09433da94cbe27 Mon Sep 17 00:00:00 2001 From: Lee Lawlor Date: Fri, 13 Feb 2015 08:47:12 -0500 Subject: [PATCH] video id fix for channels --- app/controllers/channels_controller.rb | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/app/controllers/channels_controller.rb b/app/controllers/channels_controller.rb index acabc8e..c1f02b3 100644 --- a/app/controllers/channels_controller.rb +++ b/app/controllers/channels_controller.rb @@ -195,21 +195,17 @@ class ChannelsController < ApplicationController # get the current user or find the user via their api key @user = current_user || User.find_by_api_key(get_apikey) @channel = @user.channels.find(params[:id]) + @channel.assign_attributes(channel_params) - # make updating attributes easier for updates via api - params[:channel] = params if params[:channel].blank? - - if @channel.valid? - @channel.save_tags(params[:tags][:name]) if params[:tags].present? - @channel.assign_attributes(channel_params) - @channel.set_windows - @channel.save - @channel.set_ranking - else + if !@channel.valid? flash[:alert] = @channel.errors.full_messages.join(', ') redirect_to channel_path(@channel.id, :anchor => "channelsettings") and return end + @channel.save_tags(params[:tags][:name]) if params[:tags].present? + @channel.set_windows + @channel.save + @channel.set_ranking flash[:notice] = t(:channel_update_success) respond_to do |format| format.json { render :json => @channel.to_json(Channel.private_options) }