Guest User

Untitled

a guest
May 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. <div class="col-sm-9 col-xs-12">
  2. <div class="content" role="main" id="main-content">
  3. <article>
  4. <div ><h1 align="center"><%= @child.firstname %></h1>
  5. <hr>
  6. <p>First Name: <%= @child.firstname %></p>
  7. <p>Last Name: <%= @child.lastname %></p>
  8. <p>Date of Birth:<%= @child.dateofbirth %></p>
  9. <p>Gender: <%= @child.gender %></p>
  10.  
  11.  
  12. <p>
  13. <%= link_to "Apply for funding", new_funding_path, class: "btn btn-primary btn-2x" %>
  14.  
  15. <%= link_to "Edit the child", edit_child_path(@child), class: "btn btn-primary btn-2x" %>
  16. <%= link_to "Delete this child", child_path(@child), method: :delete, data: {confirm: "Are you sure you want to delete?"}, class: "btn btn-primary btn-2x" %>|
  17. <%= link_to "Add another child", new_child_path, class: "btn btn-primary btn-2x" %></p>
  18. <hr>
  19. **<h1 align="center">Applied</h1>**
  20. <% @child.fundings.each do |funding| %>
  21. <p><strong>Status: </strong> |
  22. <strong>Type of Activity: </strong><%= funding.type_of_activity %> |
  23. <strong>Start Date: </strong><%= funding.activity_start_date %>|
  24. **<%= link_to "View this application", Funding.find_by(params[:id]), class: "btn btn-primary btn-2x" %>**
  25.  
  26. </p>
  27.  
  28. <% end %>
  29.  
  30.  
  31.  
  32. <div class="clearfix"></div></div>
  33. </article>
  34. </div>
  35. <!-- .content -->
  36. </div>
  37.  
  38. class FundingsController < ApplicationController
  39.  
  40. def index
  41. @fundings=Funding.all
  42. end
  43.  
  44. def show
  45. @funding = Funding.find(params[:id])
  46. end
  47. def new
  48. @funding = Funding.new
  49. end
  50.  
  51. def create
  52. @funding = Funding.new(funding_params)
  53.  
  54. puts child_user
  55. @funding.child = Child.find(child_user.ids[0])
  56. if @funding.save
  57. flash[:success] = "Thankyou for submitting"
  58. redirect_to funding_path(@funding)
  59. else
  60. render 'new'
  61. end
  62. end
  63.  
  64. def edit
  65. @funding = Funding.find(params[:id])
  66. end
  67.  
  68. def update
  69. @funding = Funding.find(params[:id])
  70. if @funding.update(funding_params)
  71. flash[:success] = "Your application is updated successfully"
  72. redirect_to funding_path(@funding)
  73. else
  74. render 'edit'
  75. end
  76. end
  77.  
  78. def destroy
  79. @funding = Funding.find(params[:id])
  80. @funding.destroy
  81. flash[:danger] = "Application was successfully cancelled"
  82. redirect_to child_path(@child)
  83. end
  84. private
  85.  
  86. def funding_params
  87. params.require(:funding).permit(:describe_activity, :type_of_activity, :season, :activity_details, :name_of_organisation, :activity_start_date, :number_of_weeks, :days_per_week, :hours_per_day, :program_registration_cost, :family_contribution, :other_funds, :other_fund_provider, :amount_requested, organisations_attributes: Organisation.attribute_names.map(&:to_sym).push(:_destroy))
  88. end
  89.  
  90. end
Add Comment
Please, Sign In to add comment