i have created a deposit and withdrawl method in an accounts controller, and i have configured routes. i dont know what i am doing wrong, i get this error "Missing template accounts/create, application/create with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in: * "c:/Users/geluna/Documents/Aptana Studio 3 Workspace/Luna-Kim-Kashkin/app/views" * "c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/devise-3.4.1/app/views"
my accounts controller looks like this:
class AccountsController < ApplicationController
# before_action :set_account [:show, :edit, :update, :destroy]
before_filter :authenticate_user!
respond_to :html
def index
# @accounts = Account.all
@accounts = Account.where(id:current_user.id)
if current_user.admin?
@accounts = Account.all
else
@accounts = Account.where(email:current_user.email)
end
respond_with(@accounts)
end
def show
if current_user.admin?
@accounts = Account.all
else
@accounts = Account.where(email:current_user.email)
end
respond_with(@account)
end
def new
@account = Account.new
respond_with(@account)
end
def edit
@accounts = Account.all
end
def create
#@account = Account.new(account_params)
# @account.save
# respond_with(@account)
end
def update
@account.update(account_params)
respond_with(@account)
end
def destroy
@account.destroy
respond_with(@account)
end
def withdrawl
@account = Account.new(account_params)
@account.email = current_user.email
@account.user_id = current_user.id
end
def deposit
@account = Account.new(account_params)
@account.email = current_user.email
@account.user_id = current_user.id
respond_to do |format|
@account.save
end
redirect_to :root
end
private
def set_account
#@accounts = Account.where(id:current_user.id)
@account = Account.find(params[:id])
end
def account_params
# params[:account]
params.require(:account).permit(:created_at, :email, :credit,
:debit, :acctbal, :depotype)
end
my page with the link going to the new page which has an addfunds button that leads to the "new" page an you can add a float value and press submit button and it will add funds to account and display it on the previous page .
Listing Accounts Inquiries
<h2>Your Account information</h2>
<table border="3">
<table class="table table-striped">
<thead>
<tr>
<th>Date</th>
<th>Credit</th>
<th>Debit</th>
<th>Account Balance</th>
</tr>
</thead>
<tbody>
<% @accounts.each do |account| %>
<tr>
<td><%= account.created_at %></td>
<td><b><font color="green">
<%=number_to_currency(account.credit)%></b></td>
<td><b><font color="red">
<%=number_to_currency(account.debit)%></font></b></td>
<td><b><%= number_to_currency(account.acctbal)%></b>
</td>
</tr>
<% end %>
<tbody>
</table>
</table>
<%= link_to "Add Funds", depsoit_post_path(@post),
method: :post, action: :deposit, :class => "btn btn-primary
btn-sm" %>
<table>
<thead>
<tr>
<th colspan="3"></th>
</tr>
</thead>
<% if can? :manage, Users%>
<tbody>
<% @accounts.each do |account| %>
<tr>
<td><%= link_to 'Show', account %></td>
<td><%= link_to 'Edit', edit_account_path(account) %></td>
<td><%= link_to 'Destroy', account, method: :delete, data:
{ confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
</div>
<% end %>
my routes.rb file Rails.application.routes.draw do
devise_for :users
get 'admin' => 'admin#index'
get 'users/index'
get 'accounts/index'
get 'accounts/show'
#get 'accounts/show'
# resources :accounts
resources :students
#controller :sessions do
# get 'login' => :new
# post 'login' => :create
# delete 'logout' => :destroy
#end
root 'store#index', as: 'store'
#get 'sessions/create'
#get 'sessions/destroy'
#resources :users
resources :orders
resources :line_items
resources :carts
get 'store/index'
resources :menus
resources :users
resources :accounts do
collection do
post 'deposit', :action => :deposit
post 'withdrawl', :action => :withdrawl
end
end
Aucun commentaire:
Enregistrer un commentaire