Class: Trade::Admin::PromotesController
- Inherits:
-
BaseController
- Object
- BaseController
- Trade::Admin::PromotesController
- Defined in:
- app/controllers/trade/admin/promotes_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #search ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/trade/admin/promotes_controller.rb', line 21 def create @promote = Promote.new(promote_params) if @promote.save @promote_charge = @promote.promote_charges.build else render :new, locals: { model: @promote }, status: :unprocessable_entity end end |
#destroy ⇒ Object
45 46 47 |
# File 'app/controllers/trade/admin/promotes_controller.rb', line 45 def destroy @promote.destroy end |
#edit ⇒ Object
34 35 |
# File 'app/controllers/trade/admin/promotes_controller.rb', line 34 def edit end |
#index ⇒ Object
4 5 6 7 8 9 10 |
# File 'app/controllers/trade/admin/promotes_controller.rb', line 4 def index q_params = {} q_params.merge! default_params q_params.merge! params.permit(:scope) @promotes = Promote.default_where(q_params).order(id: :desc).page(params[:page]) end |
#new ⇒ Object
17 18 19 |
# File 'app/controllers/trade/admin/promotes_controller.rb', line 17 def new @promote = Promote.new end |
#search ⇒ Object
12 13 14 15 |
# File 'app/controllers/trade/admin/promotes_controller.rb', line 12 def search @promotes = Promote.default_where('name-like': params[:q]) render json: { results: @promotes.as_json(only: [:id, :name]) } end |
#show ⇒ Object
31 32 |
# File 'app/controllers/trade/admin/promotes_controller.rb', line 31 def show end |
#update ⇒ Object
37 38 39 40 41 42 43 |
# File 'app/controllers/trade/admin/promotes_controller.rb', line 37 def update @promote.assign_attributes promote_params unless @promote.save render :edit, locals: { model: @promote }, status: :unprocessable_entity end end |