Class: FinePrint::ContractsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- FinePrint::ContractsController
- Includes:
- ApplicationHelper
- Defined in:
- app/controllers/fine_print/contracts_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #new_version ⇒ Object
- #publish ⇒ Object
- #show ⇒ Object
- #unpublish ⇒ Object
- #update ⇒ Object
Methods included from ApplicationHelper
Instance Method Details
#create ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/fine_print/contracts_controller.rb', line 22 def create @contract = Contract.new @contract.name = params[:contract][:name] @contract.title = params[:contract][:title] @contract.content = params[:contract][:content] if @contract.save redirect_to @contract, notice: t('fine_print.contract.notices.created') else render action: 'new', alert: merge_errors_for(@contract) end end |
#destroy ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'app/controllers/fine_print/contracts_controller.rb', line 56 def destroy if @contract.destroy redirect_to contracts_path, notice: t('fine_print.contract.notices.deleted') else redirect_to contracts_path, alert: merge_errors_for(@contract) end end |
#edit ⇒ Object
38 39 40 41 42 |
# File 'app/controllers/fine_print/contracts_controller.rb', line 38 def edit @contract.no_signatures redirect_to contracts_path, alert: merge_errors_for(@contract) \ unless @contract.errors.empty? end |
#index ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'app/controllers/fine_print/contracts_controller.rb', line 7 def index @contracts = Contract.select( " \"fine_print_contracts\".*, (\n SELECT COUNT(*) FROM \"fine_print_signatures\"\n WHERE \"fine_print_signatures\".\"contract_id\" = \"fine_print_contracts\".\"id\"\n ) AS \"signatures_count\"\n EOS\n ).all.to_a.group_by(&:name)\nend\n" |
#new ⇒ Object
18 19 20 |
# File 'app/controllers/fine_print/contracts_controller.rb', line 18 def new @contract = Contract.new end |
#new_version ⇒ Object
83 84 85 |
# File 'app/controllers/fine_print/contracts_controller.rb', line 83 def new_version @contract = @contract.new_version end |
#publish ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'app/controllers/fine_print/contracts_controller.rb', line 65 def publish if @contract.publish redirect_to contracts_path, notice: t('fine_print.contract.notices.published') else redirect_to contracts_path, alert: merge_errors_for(@contract) end end |
#show ⇒ Object
35 36 |
# File 'app/controllers/fine_print/contracts_controller.rb', line 35 def show end |
#unpublish ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'app/controllers/fine_print/contracts_controller.rb', line 74 def unpublish if @contract.unpublish redirect_to contracts_path, notice: t('fine_print.contract.notices.unpublished') else redirect_to contracts_path, alert: merge_errors_for(@contract) end end |
#update ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/fine_print/contracts_controller.rb', line 44 def update @contract.name = params[:contract][:name] @contract.title = params[:contract][:title] @contract.content = params[:contract][:content] if @contract.save redirect_to @contract, notice: t('fine_print.contract.notices.updated') else render action: 'edit', alert: merge_errors_for(@contract) end end |