Created
July 5, 2015 21:03
-
-
Save soilforlifeforms/6473c323d6ab394fb8ca to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<div class="panel panel-default"> | |
<%= form_for([@follow_up_visit, @follow_up_visit_garden]) do |g| %> | |
<fieldset> | |
<%= g.label :date_created, "The date the form was filled in" %> | |
<%= g.date_select (:date_created) %> <br/> | |
<%= g.label :still_gardening, "Is the gardener still gardening?" %> <br/> | |
<%= g.check_box :still_gardening %> <body> rememeber to tick if true </body> | |
</p> | |
<p> | |
<%= g.label :rating, "please rate the garden according to SFL methods and pracices" %> <br/> | |
<%= g.radio_button :rating, :one %> | |
<%= g.label :rating_1, "1, Garden not good at all, gardener not practicing SFL gardening methods." %> <br/> | |
<%= g.radio_button :rating, :two %> | |
<%= g.label :rating_1, "2, Garden not good, gardener is only practicing a few SFL gardening methods." %> <br/> | |
<%= g.radio_button :rating, :three %> | |
<%= g.label :rating_3, "3, Garden is OK, gardener is practicing some SFL methods." %> <br/> | |
<%= g.radio_button :rating, :four %> | |
<%= g.label :rating_4, "4, Garden is Good, gardener is practicing many SFL methods" %> <br/> | |
<%= g.radio_button :rating, :five %> | |
<%= g.label :rating_5, "5, Garden is Excellent, the gardener is practicing most SFL methods." %> <br/> | |
</p> | |
<p> | |
<%= g.label :mini_nursery, "Does gardener have a mini-nursery?" %> | |
<%= g.check_box :mini_nursery %> | |
</p> | |
<p> | |
<%= g.label :compost_heap, "Does gardener have a Compost heap?" %> | |
<%= g.check_box :compost_heap %> | |
</p> | |
<p> | |
<%= g.label :trench_bed, "Does gardener have a trench bed?" %> | |
<%= g.check_box :trench_bed%> | |
</p> | |
<p> | |
<%= g.label :trench_bed_sum, "How many trench beds does the gardener have?" %> <br/> | |
<%= g.number_field :trench_bed_sum %> | |
</p> | |
<p> | |
<%= g.label :container_garden, "Does gardener have a Container Garden?" %> | |
<%= g.check_box :container_garden %> | |
</p> | |
<p> | |
<%= g.label :container_garden_sum, "How many container gardens does the gardener have?" %> <br/> | |
<%= g.number_field :container_garden_sum %> | |
</p> | |
<p> | |
<%= g.label :other, "Does gardener have any other form of garden?" %> | |
<%= g.check_box :other %> | |
</p> | |
<p> | |
<%= g.label :other_qualitative, "What other kind of Garden does the gardener have?" %> | |
<%= g.text_field :other_qualitative %> | |
</p> | |
<div class="form-actions"> | |
<%= g.submit 'continue', :class => 'btn btn-lg btn-success' %> | |
<% end %> | |
</div> | |
</fieldset> |
This file contains hidden or 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
Parameters: {"utf8"=>"✓", "authenticity_token"=>"1EiutpiwecYOg542u7IJ6YQHPLK/3QMqTtr+PQ/3YO4=", "follow_up_visit_garden"=>{"date_created(1i)"=>"2015", "date_created(2i)"=>"7", "date_created(3i)"=>"5", "still_gardening"=>"1", "rating"=>"one", "mini_nursery"=>"1", "compost_heap"=>"1", "trench_bed"=>"1", "trench_bed_sum"=>"3", "container_garden"=>"1", "container_garden_sum"=>"2", "other"=>"1", "other_qualitative"=>"big ones"}, "commit"=>"continue", "follow_up_visit_id"=>"16"} | |
Parameters: {"utf8"=>"✓", "authenticity_token"=>"1EiutpiwecYOg542u7IJ6YQHPLK/3QMqTtr+PQ/3YO4=", "follow_up_visit_garden"=>{"date_created(1i)"=>"2015", "date_created(2i)"=>"7", "date_created(3i)"=>"5", "still_gardening"=>"1", "rating"=>"one", "mini_nursery"=>"1", "compost_heap"=>"1", "trench_bed"=>"1", "trench_bed_sum"=>"3", "container_garden"=>"1", "container_garden_sum"=>"2", "other"=>"1", "other_qualitative"=>"big ones"}, "commit"=>"continue", "follow_up_visit_id"=>"16"} | |
FollowUpVisit Load (0.2ms) SELECT "follow_up_visits".* FROM "follow_up_visits" WHERE "follow_up_visits"."id" = $1 LIMIT 1 [["id", 16]] | |
FollowUpVisit Load (0.2ms) SELECT "follow_up_visits".* FROM "follow_up_visits" WHERE "follow_up_visits"."id" = $1 LIMIT 1 [["id", 16]] | |
(0.2ms) BEGIN | |
(0.2ms) BEGIN | |
SQL (0.3ms) INSERT INTO "follow_up_visit_gardens" ("compost_heap", "container_garden", "container_garden_sum", "date_created", "mini_nursery", "other", "other_qualitative", "rating", "still_gardening", "trench_bed", "trench_bed_sum") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) RETURNING "id" [["compost_heap", "t"], ["container_garden", "t"], ["container_garden_sum", 2], ["date_created", "2015-07-05"], ["mini_nursery", "t"], ["other", "t"], ["other_qualitative", "big ones"], ["rating", "one"], ["still_gardening", "t"], ["trench_bed", "t"], ["trench_bed_sum", 3]] | |
SQL (0.3ms) INSERT INTO "follow_up_visit_gardens" ("compost_heap", "container_garden", "container_garden_sum", "date_created", "mini_nursery", "other", "other_qualitative", "rating", "still_gardening", "trench_bed", "trench_bed_sum") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) RETURNING "id" [["compost_heap", "t"], ["container_garden", "t"], ["container_garden_sum", 2], ["date_created", "2015-07-05"], ["mini_nursery", "t"], ["other", "t"], ["other_qualitative", "big ones"], ["rating", "one"], ["still_gardening", "t"], ["trench_bed", "t"], ["trench_bed_sum", 3]] | |
(43.8ms) COMMIT | |
(43.8ms) COMMIT | |
(0.2ms) BEGIN | |
(0.2ms) BEGIN | |
(0.1ms) COMMIT |
This file contains hidden or 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 FollowUpVisitGardensController < ApplicationController | |
def new | |
#1st you retrieve the group thanks to params[:group_id] | |
#2nd you build a new comment | |
@follow_up_visit = FollowUpVisit.find(params[:follow_up_visit_id]) | |
@follow_up_visit_garden= FollowUpVisitGarden.new | |
@gardener = @follow_up_visit.gardener | |
if @gardener.valid? | |
render "new" | |
else | |
redirect_to edit_group_gardener_path(@group, @gardener), notice: 'We are missing something in the gardener information, please complete this form first then try the follow up form again.' | |
end | |
end | |
# GET /groups/:group_id/gardeners/:id/edit | |
def edit | |
#1st you retrieve the group thanks to params[:group_id] | |
@group = Group.find(params[:group_id]) | |
#2nd you retrieve the comment thanks to params[:id] | |
@gardener= @group.gardeners.find(params[:gardener_id]) | |
@follow_up_visit_garden = @gardener.build_follow_up_visit_garden | |
end | |
# POST /groups/:group_id/group_gardeners | |
# POST /groups/:group_id/group_gardeners.xml | |
def create | |
#1st you retrieve the group thanks to params[:group_id] | |
#2nd you create the trainer wih arguments in params [:gardener] | |
@follow_up_visit = FollowUpVisit.find(params[:follow_up_visit_id]) | |
@follow_up_visit_garden = FollowUpVisitGarden.create(follow_up_visit_garden_params) | |
if @follow_up_visit_garden.save! | |
redirect_to new_follow_up_visit_follow_up_visit_eating_path(@follow_up_visit) | |
else | |
render "edit" | |
end | |
end | |
=begin | |
def update | |
#1st you retrieve the group thanks to params[:group_id] | |
@group = Group.find(params[:group_id]) | |
@gardener = group.gardeners.find(params[:id]) | |
respond_to do |format| | |
if @gardener.update_attributes(follow_up_visit_garden_params) | |
#1st argument of redirect_to is an array, in order to build the correct route to the nested resource gardener | |
format.html {redirect_to([@gardener.group, @gardener], :notice => 'what what was successfully updated')} | |
format.xml { head :ok} | |
else | |
format.html {render :action => "edit"} | |
format.xml {render :xml => @gardener.errors, :status => :unprocessable_entity} | |
end | |
end | |
=end | |
private | |
def follow_up_visit_garden_params | |
params.require(:follow_up_visit_garden).permit(:follow_up_visit_id, :date_created, :still_gardening, :rating, :mini_nursery, :compost_heap, :trench_bed, :trench_bed_sum, :container_garden, :container_garden_sum, :other, :other_qualitative) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment