forked from saurabh/personal-journal
fix error
This commit is contained in:
parent
8960d8b40f
commit
00cdad5fc7
|
@ -9,7 +9,7 @@ class PersonalJournalsController < ApplicationController
|
|||
journal_paper_query = journal_paper_query.where(:year.in => page.year.to_a )
|
||||
end
|
||||
if (!page.journal_type.blank? rescue false)
|
||||
journal_paper_query = journal_paper_query.where(:journal_type_id.in => page.journal_type.to_a )
|
||||
journal_paper_query = journal_paper_query.where(:journal_type_ids.in => page.journal_type.to_a )
|
||||
end
|
||||
journal_papers = journal_paper_query.page(OrbitHelper.params[:page_no]).per(page_data_count)
|
||||
page = Page.where(page_id: params[:page_id]).first rescue nil
|
||||
|
|
|
@ -33,7 +33,7 @@ class JournalPaper
|
|||
#relations
|
||||
belongs_to :member_profile
|
||||
belongs_to :journal_paper_type
|
||||
belongs_to :journal_type
|
||||
has_and_belongs_to_many :journal_types
|
||||
|
||||
has_and_belongs_to_many :journal_levels
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@
|
|||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_journal.journal_type") %></label>
|
||||
<div class="controls">
|
||||
<%= f.select :journal_type_id, @journal_types.collect {|t| [ t.title, t.id ]}, {include_blank: ''}, :class => "span3" %>
|
||||
<%= f.select :journal_type_ids, @journal_types.collect {|t| [ t.title, t.id ]}, {include_blank: ''}, {multiple: true}, :class => "span3" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,4 +1,14 @@
|
|||
# desc "Explaining what the task does"
|
||||
# task :personal_journal do
|
||||
# # Task goes here
|
||||
# end
|
||||
namespace :personal_journal do
|
||||
desc 'set_journal_type'
|
||||
task :set_journal_type do |task,args|
|
||||
JournalPaper.where(:rss2_id.ne=>nil).update_all({"$unset"=>{"journal_type_ids"=>""}})
|
||||
MemberTag.all.each do |mt|
|
||||
journal_type = JournalType.where(:title=>mt.title).first
|
||||
journal_type = JournalType.create(:title_translations=>mt.title_translations) if journal_type.nil?
|
||||
journal_type_id = journal_type.id
|
||||
journal_paper_ids = JournalPaper.where(:member_profile_id.in=>mt.member_profile_ids, :rss2_id.ne=>nil).pluck(:id)
|
||||
JournalPaper.where(:id.in=>journal_paper_ids).update_all({"$addToSet"=>{"journal_type_ids"=>journal_type.id}})
|
||||
# JournalType.where(:id=>journal_type_id).update_all({"$addToSet"=>{"journal_paper_ids"=>{"$each"=>journal_paper_ids}}})
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue