Class: MechanizeStore::FlagsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- MechanizeStore::FlagsController
- Defined in:
- app/controllers/mechanize_store/flags_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/mechanize_store/flags_controller.rb', line 28 def create @flag = Flag.new(flag_params) respond_with @flag do |format| if @flag.save format.html do flash[:notice] = I18n.t(:created, model: I18n.t(:flag, scope: "activerecord.models")) redirect_to @flag end else format.html { render action: "new" } end end end |
#destroy ⇒ Object
58 59 60 61 62 63 64 |
# File 'app/controllers/mechanize_store/flags_controller.rb', line 58 def destroy @flag = Flag.find(params[:id]) flash[:alert] = I18n.t(:deleted, model: I18n.t(:flag, scope: "activerecord.models")) if @flag.destroy respond_with @flag, :location => flags_url end |
#edit ⇒ Object
24 25 26 |
# File 'app/controllers/mechanize_store/flags_controller.rb', line 24 def edit respond_with @flag end |
#index ⇒ Object
7 8 9 10 11 12 13 |
# File 'app/controllers/mechanize_store/flags_controller.rb', line 7 def index @search = Flag.search(params[:q]) @flags = @search.result.paginate(page: params[:page]) respond_with @flags end |
#new ⇒ Object
19 20 21 22 |
# File 'app/controllers/mechanize_store/flags_controller.rb', line 19 def new @flag = Flag.new respond_with @flag end |
#show ⇒ Object
15 16 17 |
# File 'app/controllers/mechanize_store/flags_controller.rb', line 15 def show respond_with @flag end |
#update ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/mechanize_store/flags_controller.rb', line 43 def update @flag = Flag.find(params[:id]) respond_with @flag do |format| if @flag.update(flag_params) format.html do flash[:notice] = I18n.t(:updated, model: I18n.t(:flag, scope: "activerecord.models")) redirect_to @flag end else format.html { render action: "edit" } end end end |