From 6d48aaa8fc5be13987db863ae49a963143404ac6 Mon Sep 17 00:00:00 2001 From: Lee Lawlor Date: Thu, 27 Mar 2014 15:15:54 -0400 Subject: [PATCH] allow tags to be added when creating a channel --- app/controllers/channels_controller.rb | 1 + app/models/channel.rb | 3 ++- app/views/docs/channels/_create.html.erb | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/channels_controller.rb b/app/controllers/channels_controller.rb index 6af1197..d66607c 100644 --- a/app/controllers/channels_controller.rb +++ b/app/controllers/channels_controller.rb @@ -202,6 +202,7 @@ class ChannelsController < ApplicationController channel.set_windows channel.save + channel.save_tags(params[:channel][:tags]) if params[:channel][:tags].present? channel.add_write_api_key @channel_id = channel.id respond_to do |format| diff --git a/app/models/channel.rb b/app/models/channel.rb index 12728de..e3c7fb5 100644 --- a/app/models/channel.rb +++ b/app/models/channel.rb @@ -54,10 +54,11 @@ class Channel < ActiveRecord::Base has_many :feeds has_many :daily_feeds has_many :api_keys, :dependent => :destroy - has_many :taggings + has_many :taggings, :dependent => :destroy has_many :tags, :through => :taggings has_many :comments, :dependent => :destroy has_many :windows, :dependent => :destroy, :autosave => true + accepts_nested_attributes_for :tags self.include_root_in_json = true diff --git a/app/views/docs/channels/_create.html.erb b/app/views/docs/channels/_create.html.erb index 8559611..e98fb82 100644 --- a/app/views/docs/channels/_create.html.erb +++ b/app/views/docs/channels/_create.html.erb @@ -24,6 +24,7 @@ Valid parameters:
  • longitude (decimal) - Longitude in degrees (optional)
  • name (string) - Name of the Channel (optional)
  • public_flag (true/false) - Whether the Channel should be public, default false (optional)
  • +
  • tags (string) - Comma-separated list of tags (optional)
  • url (string) - Webpage URL for the Channel (optional)