Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ group :development do
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'bullet'
end

group :test do
Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ GEM
popper_js (>= 1.14.3, < 2)
sassc-rails (>= 2.0.0)
builder (3.2.4)
bullet (7.0.2)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.11)
byebug (11.1.3)
cancancan (3.3.0)
capybara (3.36.0)
Expand Down Expand Up @@ -408,6 +411,7 @@ GEM
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (2.1.0)
uniform_notifier (1.16.0)
warden (1.2.9)
rack (>= 2.0.9)
web-console (3.7.0)
Expand Down Expand Up @@ -435,6 +439,7 @@ DEPENDENCIES
aws-sdk-s3
bootsnap (>= 1.1.0)
bootstrap (~> 4.3.1)
bullet
byebug
cancancan
capybara
Expand Down
13 changes: 3 additions & 10 deletions app/controllers/contents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,9 @@ def new
end

def create
@master_ids = params[:content][:master_id]
@master_ids.each do |master_id|
master = Master.find(master_id.to_i)
@content = current_user.contents.create!(title: master.title, media: master.media, url: master.url, stream: master.stream, registered: false, new_flag: true, episode: master.episode, master_id: master.id)
unless current_user.limit_position(@content.stream)
current_user.schedules.create(content_id: @content.id, day: @content.stream)
@content.register
end
end
flash[:success] = "#{@master_ids.size}件のタイトルと時間割を登録しました"
master_ids = params[:content][:master_id]
Content.create_from_masters(master_ids, current_user)
flash[:success] = "#{master_ids.size}件のタイトルと時間割を登録しました"
redirect_to contents_path
end

Expand Down
11 changes: 11 additions & 0 deletions app/models/content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,15 @@ def line_on
def line_off
update(line_flag: false)
end

def self.create_from_masters(master_ids, current_user)
master_ids.each do |master_id|
master = Master.find(master_id.to_i)
content = current_user.contents.create!(title: master.title, media: master.media, url: master.url, stream: master.stream, registered: false, new_flag: true, episode: master.episode, master_id: master.id)
unless current_user.limit_position(content.stream)
current_user.schedules.create(content_id: content.id, day: content.stream)
content.register
end
end
end
end
9 changes: 9 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
Rails.application.configure do
config.after_initialize do
Bullet.enable = true
Bullet.alert = true
Bullet.bullet_logger = true
Bullet.console = true
Bullet.rails_logger = true
Bullet.add_footer = true
end

# Settings specified here will take precedence over those in config/application.rb.

# In the development environment your application's code is reloaded on
Expand Down