Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="col-sm-9 col-xs-12">
- <div class="content" role="main" id="main-content">
- <article>
- <div ><h1 align="center"><%= @child.firstname %></h1>
- <hr>
- <p>First Name: <%= @child.firstname %></p>
- <p>Last Name: <%= @child.lastname %></p>
- <p>Date of Birth:<%= @child.dateofbirth %></p>
- <p>Gender: <%= @child.gender %></p>
- <p>
- <%= link_to "Apply for funding", new_funding_path, class: "btn btn-primary btn-2x" %>
- <%= link_to "Edit the child", edit_child_path(@child), class: "btn btn-primary btn-2x" %>
- <%= 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" %>|
- <%= link_to "Add another child", new_child_path, class: "btn btn-primary btn-2x" %></p>
- <hr>
- **<h1 align="center">Applied</h1>**
- <% @child.fundings.each do |funding| %>
- <p><strong>Status: </strong> |
- <strong>Type of Activity: </strong><%= funding.type_of_activity %> |
- <strong>Start Date: </strong><%= funding.activity_start_date %>|
- **<%= link_to "View this application", Funding.find_by(params[:id]), class: "btn btn-primary btn-2x" %>**
- </p>
- <% end %>
- <div class="clearfix"></div></div>
- </article>
- </div>
- <!-- .content -->
- </div>
- class FundingsController < ApplicationController
- def index
- @fundings=Funding.all
- end
- def show
- @funding = Funding.find(params[:id])
- end
- def new
- @funding = Funding.new
- end
- def create
- @funding = Funding.new(funding_params)
- puts child_user
- @funding.child = Child.find(child_user.ids[0])
- if @funding.save
- flash[:success] = "Thankyou for submitting"
- redirect_to funding_path(@funding)
- else
- render 'new'
- end
- end
- def edit
- @funding = Funding.find(params[:id])
- end
- def update
- @funding = Funding.find(params[:id])
- if @funding.update(funding_params)
- flash[:success] = "Your application is updated successfully"
- redirect_to funding_path(@funding)
- else
- render 'edit'
- end
- end
- def destroy
- @funding = Funding.find(params[:id])
- @funding.destroy
- flash[:danger] = "Application was successfully cancelled"
- redirect_to child_path(@child)
- end
- private
- def funding_params
- 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))
- end
- end
Add Comment
Please, Sign In to add comment