Skip to content

Instantly share code, notes, and snippets.

@Haguilar91
Last active June 14, 2018 04:42
Show Gist options
  • Save Haguilar91/fc3faa38438dd803e098c40833e5db2b to your computer and use it in GitHub Desktop.
Save Haguilar91/fc3faa38438dd803e098c40833e5db2b to your computer and use it in GitHub Desktop.
Intento de Modal para crear Transaccion
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Metodos de Pago</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<%= form_for(@transaction) do |form| %>
<div class="form-group">
<div class="field">
<%= form.label :id_vend %>
<%= form.text_field :id_vend %>
</div>
<div class="field">
<%= form.label :id_comp %>
<%= form.text_field :id_comp %>
</div>
<div class="field">
<%= form.label :id_item %>
<%= form.text_field :id_item %>
</div>
<div class="field">
<%= form.label :voucher %>
<%= form.text_field :voucher %>
</div>
<div class="field">
<%= form.label :isComplete %>
<%= form.check_box :isComplete %>
</div>
</div>
</div>
<div class="modal-footer">
<div class="form-group">
<%= form.submit "Crear Transaccion", class: "btn btn-warning" %>
</div>
<% end %>
</div>
$("#pagosModal").html.find(".modal-content").html("<%= escape_javascript(render 'transactions/new') %>");
$("#pagosModal").modal('show');
<!-- Invocando Modal-->
<!--Intento 1-->
<%= link_to 'Pedir informacion de pago', new_transaction_path, {:remote => true,'data-toggle' => "modal", 'data-target' => '#pagosModal', :class=>"btn btn-outline-danger"} %>
<hr>
<!--Intento 2-->
<%= link_to 'trigger modal', new_transaction_path , remote: true, data: { target: '#pagosModal', toggle: 'modal' }, class: 'nav-link'%>
<!-- MODAL METODOS DE PAGO-->
<div class="modal fade" id="pagosModal" tabindex="-1" role="dialog" aria-labelledby="pagosModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
</div>
</div>
</div>
<!--Fin Modal Metodos de Pago-->
# == Route Map
#
# Prefix Verb URI Pattern Controller#Action
# api_v1_items GET /api/v1/items(.:format) api/v1/items#index
# POST /api/v1/items(.:format) api/v1/items#create
# new_api_v1_item GET /api/v1/items/new(.:format) api/v1/items#new
# edit_api_v1_item GET /api/v1/items/:id/edit(.:format) api/v1/items#edit
# api_v1_item GET /api/v1/items/:id(.:format) api/v1/items#show
# PATCH /api/v1/items/:id(.:format) api/v1/items#update
# PUT /api/v1/items/:id(.:format) api/v1/items#update
# DELETE /api/v1/items/:id(.:format) api/v1/items#destroy
# root GET / welcome#index
# comment_items GET /comment_items(.:format) comment_items#index
# POST /comment_items(.:format) comment_items#create
# new_comment_item GET /comment_items/new(.:format) comment_items#new
# edit_comment_item GET /comment_items/:id/edit(.:format) comment_items#edit
# comment_item GET /comment_items/:id(.:format) comment_items#show
# PATCH /comment_items/:id(.:format) comment_items#update
# PUT /comment_items/:id(.:format) comment_items#update
# DELETE /comment_items/:id(.:format) comment_items#destroy
# comments GET /comments(.:format) comments#index
# POST /comments(.:format) comments#create
# new_comment GET /comments/new(.:format) comments#new
# edit_comment GET /comments/:id/edit(.:format) comments#edit
# comment GET /comments/:id(.:format) comments#show
# PATCH /comments/:id(.:format) comments#update
# PUT /comments/:id(.:format) comments#update
# DELETE /comments/:id(.:format) comments#destroy
# feedbacks GET /feedbacks(.:format) feedbacks#index
# POST /feedbacks(.:format) feedbacks#create
# new_feedback GET /feedbacks/new(.:format) feedbacks#new
# edit_feedback GET /feedbacks/:id/edit(.:format) feedbacks#edit
# feedback GET /feedbacks/:id(.:format) feedbacks#show
# PATCH /feedbacks/:id(.:format) feedbacks#update
# PUT /feedbacks/:id(.:format) feedbacks#update
# DELETE /feedbacks/:id(.:format) feedbacks#destroy
# autocomplete_items GET /items/autocomplete(.:format) items#autocomplete
# items GET /items(.:format) items#index
# POST /items(.:format) items#create
# new_item GET /items/new(.:format) items#new
# edit_item GET /items/:id/edit(.:format) items#edit
# item GET /items/:id(.:format) items#show
# PATCH /items/:id(.:format) items#update
# PUT /items/:id(.:format) items#update
# DELETE /items/:id(.:format) items#destroy
# walls GET /walls(.:format) walls#index
# POST /walls(.:format) walls#create
# new_wall GET /walls/new(.:format) walls#new
# edit_wall GET /walls/:id/edit(.:format) walls#edit
# wall GET /walls/:id(.:format) walls#show
# PATCH /walls/:id(.:format) walls#update
# PUT /walls/:id(.:format) walls#update
# DELETE /walls/:id(.:format) walls#destroy
# user_facebook_omniauth_authorize GET|POST /users/auth/facebook(.:format) users/omniauth_callbacks#passthru
# user_facebook_omniauth_callback GET|POST /users/auth/facebook/callback(.:format) users/omniauth_callbacks#facebook
# new_user_session GET /users/sign_in(.:format) devise/sessions#new
# user_session POST /users/sign_in(.:format) devise/sessions#create
# destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
# new_user_password GET /users/password/new(.:format) devise/passwords#new
# edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
# user_password PATCH /users/password(.:format) devise/passwords#update
# PUT /users/password(.:format) devise/passwords#update
# POST /users/password(.:format) devise/passwords#create
# cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel
# new_user_registration GET /users/sign_up(.:format) devise/registrations#new
# edit_user_registration GET /users/edit(.:format) devise/registrations#edit
# user_registration PATCH /users(.:format) devise/registrations#update
# PUT /users(.:format) devise/registrations#update
# DELETE /users(.:format) devise/registrations#destroy
# POST /users(.:format) devise/registrations#create
# add_user GET /add_user(.:format) walls#add_user
# show_another_user GET /show_another_user(.:format) walls#show_another_user
# garaje_todos GET /garaje/todos(.:format) walls#show_all_garages
# GET /garaje/:user_id(.:format) walls#show_another_user
# GET /garaje/items/:item_id(.:format) walls#show_public_item
# GET /comments/:user_id(.:format) comments#index
# conversations_new GET /conversations/new(.:format) conversations#new
# garaje_todos_search GET /garaje/todos/search(.:format) walls#show_all_garages
# show_user_items_category GET /show_user_items_category(.:format) walls#show_user_items_category
# show_user_profile GET /show_user_profile(.:format) walls#show_user_profile
# show_index GET /show_index(.:format) walls#show_index
# delete_user GET /delete_user(.:format) walls#delete_user
# buscar GET /buscar(.:format) walls#buscar
# buscar_garajes GET /buscar_garajes(.:format) walls#buscar_garajes
# GET|POST /auth/:provider/callback(.:format) sessions#create
# auth_failure GET|POST /auth/failure(.:format) redirect(301, /)
# conversation_messages GET /conversations/:conversation_id/messages(.:format) messages#index
# POST /conversations/:conversation_id/messages(.:format) messages#create
# new_conversation_message GET /conversations/:conversation_id/messages/new(.:format) messages#new
# edit_conversation_message GET /conversations/:conversation_id/messages/:id/edit(.:format) messages#edit
# conversation_message GET /conversations/:conversation_id/messages/:id(.:format) messages#show
# PATCH /conversations/:conversation_id/messages/:id(.:format) messages#update
# PUT /conversations/:conversation_id/messages/:id(.:format) messages#update
# DELETE /conversations/:conversation_id/messages/:id(.:format) messages#destroy
# conversations GET /conversations(.:format) conversations#index
# POST /conversations(.:format) conversations#create
# new_conversation GET /conversations/new(.:format) conversations#new
# edit_conversation GET /conversations/:id/edit(.:format) conversations#edit
# conversation GET /conversations/:id(.:format) conversations#show
# PATCH /conversations/:id(.:format) conversations#update
# PUT /conversations/:id(.:format) conversations#update
# DELETE /conversations/:id(.:format) conversations#destroy
# GET /*path(.:format) redirect(301, /)
#
Rails.application.routes.draw do
resources :partners
resources :orders
resources :transactions
namespace :api do
namespace :v1 do
resources :items
end
end
root :to => 'welcome#index'
resources :comment_items
resources :comments
resources :feedbacks
resources :items do
collection do
get :autocomplete
end
end
resources :walls
get '/check_paypal' => 'paypal#checkipn'
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
get '/add_user' => 'walls#add_user'
get '/show_another_user' => "walls#show_another_user"
get '/garaje/todos' => "walls#show_all_garages"
get '/garaje/:user_id' => "walls#show_another_user"
get '/garaje/items/:item_id' => "walls#show_public_item"
get '/comments/:user_id' => "comments#index"
get '/conversations/new' => 'conversations#new'
get '/garaje/todos/search' => "walls#show_all_garages"
get '/show_user_items_category' => 'walls#show_user_items_category'
get '/show_user_profile' => 'walls#show_user_profile'
get '/show_index' => 'walls#show_index'
get '/delete_user' => "walls#delete_user"
get '/buscar' => 'walls#buscar'
get '/buscar_garajes' => 'walls#buscar_garajes'
# get "/new_transaccion" => 'transactions#new', :as => :new_transaccion
#get "transactions/new" => 'transactions#new_transaccion', :as => :new_transaction
# get "posts/new" => 'posts#new_post', :as => :post
match 'auth/:provider/callback', to: 'sessions#create', via: [:get, :post]
match 'auth/failure', to: redirect('/'), via: [:get, :post]
# match 'signout', to: 'sessions#destroy', as: 'signout', via: [:post]
# resources :lenders
# resources :loans
# devise_scope :user do
# get '/users/sign_out' => 'devise/sessions#destroy'
# end
resources :conversations do
resources :messages
end
match '*path' => redirect('/'), via: :get
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# # resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end
class TransactionsController < ApplicationController
before_action :set_transaction, only: [:show, :edit, :update, :destroy]
# GET /transactions
# GET /transactions.json
def index
@transactions = Transaction.all
end
# GET /transactions/1
# GET /transactions/1.json
def show
@transaction = Transaction.find_by_id(params[:id])
end
# GET /transactions/new
def new
@transaction = Transaction.new
respond_to do |format|
format.html
format.js
end
end
# GET /transactions/1/edit
def edit
end
# POST /transactions
# POST /transactions.json
def create
@transaction = Transaction.new(transaction_params)
respond_to do |format|
if @transaction.save
format.html { redirect_to @transaction, notice: 'Transaction was successfully created.' }
format.json { render :show, status: :created, location: @transaction }
else
format.html { render :new }
format.json { render json: @transaction.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /transactions/1
# PATCH/PUT /transactions/1.json
def update
respond_to do |format|
if @transaction.update(transaction_params)
format.html { redirect_to @transaction, notice: 'Transaction was successfully updated.' }
format.json { render :show, status: :ok, location: @transaction }
else
format.html { render :edit }
format.json { render json: @transaction.errors, status: :unprocessable_entity }
end
end
end
# DELETE /transactions/1
# DELETE /transactions/1.json
def destroy
@transaction.destroy
respond_to do |format|
format.html { redirect_to transactions_url, notice: 'Transaction was successfully destroyed.' }
format.json { head :no_content }
end
end
#def new_transaccion
# @transaction = Transaction.new
# respond_to do |format|
# format.html
# format.js
# end
#end
private
# Use callbacks to share common setup or constraints between actions.
def set_transaction
@transaction = Transaction.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def transaction_params
params.require(:transaction).permit(:id_vend, :id_comp, :id_item, :voucher, :isComplete)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment