Forked from renatosousafilho/ 20140331025708_create_cashes.rb
Last active
August 29, 2015 13:57
-
-
Save matheusvetor/9891957 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateCashes < ActiveRecord::Migration | |
def change | |
create_table :cashes do |t| | |
t.datetime :start_at | |
t.datetime :end_at | |
t.decimal :value_open | |
t.decimal :value_phisic_closed | |
t.decimal :value_system_closed | |
t.timestamps | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= simple_form_for @cash do |f| %> | |
<div class="form-group"> | |
<%= f.input :value_open, :input_html =>{:class=>"form-control"} %> | |
</div> | |
<%= button_tag(type: :submit, :class=>"btn btn-success") do %> | |
<i class="icon-save"></i> Registar abertura de caixa | |
<% end %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
before_filter :authenticate_user! | |
before_filter :authenticate_cash | |
def after_sign_in_path_for(resource) | |
new_cash_path | |
end | |
def authenticate_cash | |
redirect_to new_cah_path if session[:cash_id].nil? | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CashesController < ApplicationController | |
def index | |
start_at = current_user.current_sign_in_at | |
@billings = Billing.where("created_at>?",start_at) | |
end | |
def new | |
@cash = Cash.new | |
end | |
def create | |
@cash = Cash.new(cash_params) | |
@cash.start_at = current_user.current_sign_in_at | |
if @cash.save | |
session[:cash_id] = @cash.id | |
redirect_to root_url | |
end | |
end | |
def cash_params | |
params.require(:cash).permit(:value_open, :value_phisic_closed, :value_system_closed) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cashing < ActiveRecord::Base | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment