Class: Cullender::RulesController
- Inherits:
-
CullenderController
- Object
- CullenderController
- Cullender::RulesController
- Includes:
- Controllers::FilterLogic
- Defined in:
- app/controllers/cullender/rules_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /rules.
-
#destroy ⇒ Object
DELETE /rules/1.
-
#index ⇒ Object
TODO should route without resource.
-
#new ⇒ Object
GET /rules/new.
-
#show ⇒ Object
GET /rules/1.
-
#update ⇒ Object
PATCH/PUT /rules/1.
Methods included from Controllers::FilterLogic
#add_and_filter, #add_operator, #add_or_filter, #apply_filter_actions, #clean_field, #remove_and_filter
Methods inherited from CullenderController
#_prefixes, #cullender_mapping, #resource, #resource_class, #resource_name, #resource_params
Instance Method Details
#create ⇒ Object
POST /rules
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/cullender/rules_controller.rb', line 24 def create flag = apply_filter_actions("triggers", params[:rule], params) @rule = Cullender::Rule.new(rule_params) respond_to do |format| if flag format.html {redirect_to send("new_#{resource_name}_rule_url".to_sym,params[:rule])} format.js { render "create"} else if @rule.save format.html {redirect_to send("#{resource_name}_rules_url".to_sym), notice: 'Rule was successfully created.'} format.js {redirect_to send("#{resource_name}_rules_url".to_sym), notice: 'Rule was successfully created.'} else format.html {render action: 'new'} format.js {render action: 'new'} end end end end |
#destroy ⇒ Object
DELETE /rules/1
54 55 56 57 58 |
# File 'app/controllers/cullender/rules_controller.rb', line 54 def destroy @rule = Cullender::Rule.find(params[:id]) @rule.destroy redirect_to send("#{resource_name}_rules_url".to_sym), notice: 'Rule was successfully destroyed.' end |
#index ⇒ Object
TODO should route without resource. ie not event/rules just /rules GET /rules
8 9 10 |
# File 'app/controllers/cullender/rules_controller.rb', line 8 def index @rules = Cullender::Rule.all end |
#new ⇒ Object
GET /rules/new
19 20 21 |
# File 'app/controllers/cullender/rules_controller.rb', line 19 def new @rule = Cullender::Rule.new(name: params[:name]) end |
#show ⇒ Object
GET /rules/1
13 14 15 16 |
# File 'app/controllers/cullender/rules_controller.rb', line 13 def show @rule = Cullender::Rule.find(params[:id]) params.deep_merge!({"rule" => {"triggers" => @rule.triggers}}) end |
#update ⇒ Object
PATCH/PUT /rules/1
44 45 46 47 48 49 50 51 |
# File 'app/controllers/cullender/rules_controller.rb', line 44 def update @rule = Cullender::Rule.find(params[:id]) if !apply_filter_actions("triggers", params[:rule], params) && @rule.update_attributes(rule_params) redirect_to send("#{resource_name}_rules_url".to_sym), notice: 'Rule was successfully updated.' else render action: 'show' end end |