Merge pull request #1301 from amiedes/patch
Remove duplicated code in Admin::BannersController
This commit is contained in:
@@ -2,7 +2,6 @@ class Admin::BannersController < Admin::BaseController
|
|||||||
|
|
||||||
has_filters %w{all with_active with_inactive}, only: :index
|
has_filters %w{all with_active with_inactive}, only: :index
|
||||||
|
|
||||||
before_action :find_banner, only: [:edit, :update, :destroy]
|
|
||||||
before_action :banner_styles, only: [:edit, :new, :create, :update]
|
before_action :banner_styles, only: [:edit, :new, :create, :update]
|
||||||
before_action :banner_imgs, only: [:edit, :new, :create, :update]
|
before_action :banner_imgs, only: [:edit, :new, :create, :update]
|
||||||
|
|
||||||
@@ -24,7 +23,6 @@ class Admin::BannersController < Admin::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@banner.assign_attributes(banner_params)
|
|
||||||
if @banner.update(banner_params)
|
if @banner.update(banner_params)
|
||||||
redirect_to admin_banners_path
|
redirect_to admin_banners_path
|
||||||
else
|
else
|
||||||
@@ -43,10 +41,6 @@ class Admin::BannersController < Admin::BaseController
|
|||||||
params.require(:banner).permit(:title, :description, :target_url, :style, :image, :post_started_at, :post_ended_at)
|
params.require(:banner).permit(:title, :description, :target_url, :style, :image, :post_started_at, :post_ended_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_banner
|
|
||||||
@banner = Banner.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def banner_styles
|
def banner_styles
|
||||||
@banner_styles = Setting.all.banner_style.map { |banner_style| [banner_style.value, banner_style.key.split('.')[1]] }
|
@banner_styles = Setting.all.banner_style.map { |banner_style| [banner_style.value, banner_style.key.split('.')[1]] }
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user