Fix relations error in tags
This commit is contained in:
parent
778a85ca2b
commit
d0c2856a3a
|
@ -19,7 +19,7 @@ class Admin::TagsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@tag = Tag.create(params[:tag])
|
@tag = (params[:tag][:module_app_id].blank? ? Tag.create(params[:tag]) : ModuleAppTag.create(params[:tag]))
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|
|
@ -21,8 +21,4 @@ class I18nVariable
|
||||||
I18nVariable.first(:conditions => {:key => locale})[I18n.locale]
|
I18nVariable.first(:conditions => {:key => locale})[I18n.locale]
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.from_locale(locale)
|
|
||||||
I18nVariable.first(:conditions => {:key => locale})[I18n.locale]
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,5 @@ class Tag
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
|
|
||||||
belongs_to :module_app
|
belongs_to :module_app
|
||||||
has_and_belongs_to_many :bulletins
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<%= form_for tag, :url => admin_tag_path(tag), :remote => true do |f| %>
|
<%= form_for :tag, :url => admin_tag_path(tag), :method => :put, :remote => true do |f| %>
|
||||||
<% @site_valid_locales.each do |locale| %>
|
<% @site_valid_locales.each do |locale| %>
|
||||||
<%= I18nVariable.from_locale(locale) %>:<%= f.text_field locale %>
|
<%= I18nVariable.from_locale(locale) %>:<%= f.text_field locale %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -8,7 +8,7 @@ class Bulletin
|
||||||
has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
||||||
has_one :subtitle, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
has_one :subtitle, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
||||||
has_one :text, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
has_one :text, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
||||||
has_and_belongs_to_many :tags
|
has_and_belongs_to_many :tags, :class_name => "ModuleAppTag"
|
||||||
|
|
||||||
field :postdate , :type => Date
|
field :postdate , :type => Date
|
||||||
field :deadline , :type => Date
|
field :deadline , :type => Date
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class ModuleAppTag < Tag
|
||||||
|
|
||||||
|
has_and_belongs_to_many :bulletins
|
||||||
|
|
||||||
|
end
|
Reference in New Issue