From b2eefd81639bcd54296a8dde0dd2c1d1e35af23b Mon Sep 17 00:00:00 2001 From: Jason Denney Date: Sun, 9 Dec 2012 18:11:18 -0500 Subject: [PATCH] actsasloggable transaction actions fixtures, resources, controller, and views --- .../transaction_actions_controller.rb | 36 +++++++++++++++++++ .../transaction_actions/_form.html.haml | 8 +++++ .../transaction_actions/edit.html.haml | 4 +++ .../transaction_actions/index.html.haml | 21 +++++++++++ .../transaction_actions/new.html.haml | 4 +++ .../transaction_actions/show.html.haml | 13 +++++++ config/routes.rb | 1 + .../acts_as_loggable/transaction_actions.yml | 25 +++++++++++++ 8 files changed, 112 insertions(+) create mode 100644 app/controllers/acts_as_loggable/transaction_actions_controller.rb create mode 100644 app/views/acts_as_loggable/transaction_actions/_form.html.haml create mode 100644 app/views/acts_as_loggable/transaction_actions/edit.html.haml create mode 100644 app/views/acts_as_loggable/transaction_actions/index.html.haml create mode 100644 app/views/acts_as_loggable/transaction_actions/new.html.haml create mode 100644 app/views/acts_as_loggable/transaction_actions/show.html.haml create mode 100644 db/seed/fixtures/acts_as_loggable/transaction_actions.yml diff --git a/app/controllers/acts_as_loggable/transaction_actions_controller.rb b/app/controllers/acts_as_loggable/transaction_actions_controller.rb new file mode 100644 index 0000000..a5cb0d0 --- /dev/null +++ b/app/controllers/acts_as_loggable/transaction_actions_controller.rb @@ -0,0 +1,36 @@ +class ActsAsLoggable::TransactionActionsController < AuthenticatedController + #TODO Fix this so updating works + expose(:transaction_action) + expose(:transaction_actions) { ActsAsLoggable::TransactionAction.order('id').paginate(:page => params[:page]) } + + def index + end + + def show + end + + def new + end + + def create + if transaction_action.save + redirect_to acts_as_loggable_transaction_actions_url + else + render :new + end + end + + def update + puts transaction_action.inspect + if transaction_action.save + redirect_to acts_as_loggable_transaction_actions_url + else + render :edit + end + end + + def destroy + transaction_action.destroy + redirect_to acts_as_loggable_transaction_actions_url + end +end diff --git a/app/views/acts_as_loggable/transaction_actions/_form.html.haml b/app/views/acts_as_loggable/transaction_actions/_form.html.haml new file mode 100644 index 0000000..b9f369d --- /dev/null +++ b/app/views/acts_as_loggable/transaction_actions/_form.html.haml @@ -0,0 +1,8 @@ += form_for transaction_action, :html => { :class => 'form-horizontal' } do |f| + .control-group + = f.label :action, :class => 'control-label' + .controls + = f.text_field :action, :class => 'text_field' + .form-actions + = f.submit nil, :class => 'btn btn-primary' + = link_to t('.cancel', :default => t("helpers.links.cancel")), acts_as_loggable_transaction_actions_path, :class => 'btn' diff --git a/app/views/acts_as_loggable/transaction_actions/edit.html.haml b/app/views/acts_as_loggable/transaction_actions/edit.html.haml new file mode 100644 index 0000000..5ace00d --- /dev/null +++ b/app/views/acts_as_loggable/transaction_actions/edit.html.haml @@ -0,0 +1,4 @@ +- model_class = transaction_action.class +.page-header + %h1=t '.title', :default => t('helpers.titles.edit', :model => model_class.model_name.human, :default => "Edit #{model_class.model_name.human}") += render :partial => "form" diff --git a/app/views/acts_as_loggable/transaction_actions/index.html.haml b/app/views/acts_as_loggable/transaction_actions/index.html.haml new file mode 100644 index 0000000..a05f3f3 --- /dev/null +++ b/app/views/acts_as_loggable/transaction_actions/index.html.haml @@ -0,0 +1,21 @@ +- model_class = ActsAsLoggable::TransactionAction.new.class +.page-header + %h1=t '.title', :default => model_class.model_name.human.pluralize +%table.table.table-striped + %thead + %tr + %th= model_class.human_attribute_name(:id) + %th= model_class.human_attribute_name(:action) + %th= model_class.human_attribute_name(:created_at) + %th=t '.actions', :default => t("helpers.actions") + %tbody + - transaction_actions.each do |transaction_action| + %tr + %td= link_to transaction_action.id, acts_as_loggable_transaction_action_path(transaction_action) + %td= transaction_action.action + %td=l transaction_action.created_at + %td + = link_to t('.edit', :default => t("helpers.links.edit")), edit_acts_as_loggable_transaction_action_path(transaction_action), :class => 'btn btn-mini' + = link_to t('.destroy', :default => t("helpers.links.destroy")), acts_as_loggable_transaction_action_path(transaction_action), :method => :delete, :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')), :class => 'btn btn-mini btn-danger' + += link_to t('.new', :default => t("helpers.links.new")), new_acts_as_loggable_transaction_action_path, :class => 'btn btn-primary' diff --git a/app/views/acts_as_loggable/transaction_actions/new.html.haml b/app/views/acts_as_loggable/transaction_actions/new.html.haml new file mode 100644 index 0000000..721da05 --- /dev/null +++ b/app/views/acts_as_loggable/transaction_actions/new.html.haml @@ -0,0 +1,4 @@ +- model_class = transaction_action.class +.page-header + %h1=t '.title', :default => t('helpers.titles.new', :model => model_class.model_name.human, :default => "New #{model_class.model_name.human}") += render :partial => "form" diff --git a/app/views/acts_as_loggable/transaction_actions/show.html.haml b/app/views/acts_as_loggable/transaction_actions/show.html.haml new file mode 100644 index 0000000..a15b1a6 --- /dev/null +++ b/app/views/acts_as_loggable/transaction_actions/show.html.haml @@ -0,0 +1,13 @@ +- model_class = transaction_action.class +.page-header + %h1=t '.title', :default => model_class.model_name.human + +%p + %strong= model_class.human_attribute_name(:action) + ':' + %br + = transaction_action.action + +.form-actions + = link_to t('.back', :default => t("helpers.links.back")), acts_as_loggable_transaction_actions_path, :class => 'btn' + = link_to t('.edit', :default => t("helpers.links.edit")), edit_acts_as_loggable_transaction_action_path(transaction_action), :class => 'btn' + = link_to t('.destroy', :default => t("helpers.links.destroy")), acts_as_loggable_transaction_action_path(transaction_action), :method => "delete", :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')), :class => 'btn btn-danger' diff --git a/config/routes.rb b/config/routes.rb index 9bceb33..5a4a90a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -17,6 +17,7 @@ Velocipede::Application.routes.draw do namespace :acts_as_loggable do resources :bike_actions resources :user_actions + resources :transaction_actions end #resources :clues #resources :maps diff --git a/db/seed/fixtures/acts_as_loggable/transaction_actions.yml b/db/seed/fixtures/acts_as_loggable/transaction_actions.yml new file mode 100644 index 0000000..a3193bc --- /dev/null +++ b/db/seed/fixtures/acts_as_loggable/transaction_actions.yml @@ -0,0 +1,25 @@ +time: + id: 1 + action: TIME + created_at: <%= Time.now %> + updated_at: <%= Time.now %> +borrow: + id: 2 + action: BORROW + created_at: <%= Time.now %> + updated_at: <%= Time.now %> +cash: + id: 3 + action: CASH + created_at: <%= Time.now %> + updated_at: <%= Time.now %> +check: + id: 4 + action: CHECK + created_at: <%= Time.now %> + updated_at: <%= Time.now %> +credit: + id: 5 + action: CREDIT + created_at: <%= Time.now %> + updated_at: <%= Time.now %>