removed old methods to create tags
This commit is contained in:
parent
14017bfa66
commit
d0c1d488fc
|
@ -196,7 +196,6 @@ end
|
||||||
|
|
||||||
def add_entry
|
def add_entry
|
||||||
entry = TableEntry.new(table_entry_params)
|
entry = TableEntry.new(table_entry_params)
|
||||||
create_get_table_tags(entry)
|
|
||||||
entry.save
|
entry.save
|
||||||
entry.fix_have_data
|
entry.fix_have_data
|
||||||
table = UTable.find(params[:table_entry][:u_table_id])
|
table = UTable.find(params[:table_entry][:u_table_id])
|
||||||
|
@ -222,7 +221,6 @@ end
|
||||||
|
|
||||||
def update_entry
|
def update_entry
|
||||||
entry = TableEntry.find(params[:id])
|
entry = TableEntry.find(params[:id])
|
||||||
create_get_table_tags(entry)
|
|
||||||
entry.update_attributes(table_entry_params)
|
entry.update_attributes(table_entry_params)
|
||||||
entry.fix_have_data # when new column insert
|
entry.fix_have_data # when new column insert
|
||||||
table = entry.u_table
|
table = entry.u_table
|
||||||
|
@ -322,27 +320,4 @@ end
|
||||||
params.require(:table_entry).permit!
|
params.require(:table_entry).permit!
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_get_table_tags(entry,new_tags=nil)
|
|
||||||
if new_tags.nil?
|
|
||||||
new_tags = params["table_tags"].split(",")
|
|
||||||
end
|
|
||||||
tags = []
|
|
||||||
entry.table_tags = []
|
|
||||||
new_tags.each do |tag|
|
|
||||||
if is_uuid?(tag) === false
|
|
||||||
tt = TableTag.new
|
|
||||||
tt.u_table_id = entry.u_table.id
|
|
||||||
tt.title = tag.downcase.strip
|
|
||||||
tt.save
|
|
||||||
entry.table_tags << tt
|
|
||||||
else
|
|
||||||
tt = TableTag.find(tag)
|
|
||||||
entry.table_tags << tt
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return tags
|
|
||||||
end
|
|
||||||
def is_uuid?(str)
|
|
||||||
!!(str =~ /\A[\da-f]{24}\z/i || str =~ /\A[\da-f]{8}-([\da-f]{4}-){3}[\da-f]{12}\z/i)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue