Merge pull request #1184 from Br3nda/bw/grand-haml-cleanup-of-2017

Haml clean up -- crops views
This commit is contained in:
Daniel O'Connor
2017-02-06 11:47:47 +10:30
committed by GitHub
28 changed files with 154 additions and 102 deletions

View File

@@ -28,6 +28,7 @@ before_script:
- bundle exec rake assets:precompile
script:
- bundle exec rubocop --display-cop-names --rails
- bundle exec haml-lint app/views/account_types app/views/admin app/views/alternate_names app/views/account_types app/views/comments app/views/crops
- script/gemfile_check
- bundle exec script/check_contributors_md
- bundle exec rake db:migrate --trace

View File

@@ -18,4 +18,8 @@ module CropsHelper
"You have an unknown quantity of seeds of this crop."
end
end
def crop_ebay_seeds_url(crop)
"http://rover.ebay.com/rover/1/705-53470-19255-0/1?icep_ff3=9&pub=5575213277&toolid=10001&campid=5337940151&customid=&icep_uq=#{URI.escape crop.name}&icep_sellerId=&icep_ex_kw=&icep_sortBy=12&icep_catId=181003&icep_minPrice=&icep_maxPrice=&ipn=psmain&icep_vectorid=229515&kwid=902099&mtid=824&kw=lg" # rubocop:disable Metrics/LineLength
end
end

View File

@@ -163,11 +163,11 @@ class Crop < ActiveRecord::Base
# key: plant part (eg. 'fruit')
# value: count of how many times it's been used by harvests
def popular_plant_parts
popular_plant_parts = Hash.new(0)
harvests.each do |h|
popular_plant_parts[h.plant_part] += 1 if h.plant_part
end
popular_plant_parts
PlantPart.joins(:harvests)
.where("crop_id = ?", id)
.order("count_harvests_id DESC")
.group("plant_parts.id", "plant_parts.name")
.count("harvests.id")
end
def interesting?

View File

@@ -11,7 +11,10 @@
%p
= link_to "View all #{crop.name} seeds", seeds_by_crop_path(crop)
%p
= link_to "Purchase seeds via Ebay", "http://rover.ebay.com/rover/1/705-53470-19255-0/1?icep_ff3=9&pub=5575213277&toolid=10001&campid=5337940151&customid=&icep_uq=#{URI.escape crop.name}&icep_sellerId=&icep_ex_kw=&icep_sortBy=12&icep_catId=181003&icep_minPrice=&icep_maxPrice=&ipn=psmain&icep_vectorid=229515&kwid=902099&mtid=824&kw=lg", target: "_blank", rel: "noopener noreferrer"
= link_to "Purchase seeds via Ebay",
crop_ebay_seeds_url(crop),
target: "_blank",
rel: "noopener noreferrer"
- if crop.approved?
- if current_member
%p= link_to "List #{crop.name} seeds to trade", new_seed_path(crop_id: crop.id)

View File

@@ -104,7 +104,7 @@
.form-group
= f.label :reason_for_rejection, 'Reason for rejection', class: 'control-label col-md-2'
.col-md-8
= f.select(:reason_for_rejection, @crop.reasons_for_rejection, { include_blank: true }, { class: 'form-control' })
= f.select(:reason_for_rejection, @crop.reasons_for_rejection, include_blank: true, class: 'form-control')
.form-group
= f.label :rejection_notes, 'Rejection notes', class: 'control-label col-md-2'
@@ -113,7 +113,6 @@
%span.help-block
Please provide additional notes why this crop request was rejected if the above reasons do not apply.
.form-group
.form-actions.col-md-offset-2.col-md-8
= f.submit 'Save', class: 'btn btn-primary'

View File

@@ -3,5 +3,7 @@
- if crop.harvests.empty?
not known.
- else
- popular_plant_parts = crop.popular_plant_parts.sort_by {|s, freq| freq }.reverse
!= popular_plant_parts.map {|p, freq| link_to(p, p) + " (#{freq})" }.join(", ")
- crop.popular_plant_parts.each do |plant_part, frequency|
- id, name = plant_part
= link_to name, plant_part_path(id: id)
(#{frequency})

View File

@@ -1,4 +1,4 @@
%h4 #{ crop.name.capitalize } harvests
%h4 #{crop.name.capitalize} harvests
- if crop.harvests.empty?
%p
Nobody has harvested this crop yet.
@@ -17,5 +17,4 @@
- if current_member
%p= link_to "Harvest #{crop.name}", new_harvest_path(crop_id: crop.id)
- else
= render partial: 'shared/signin_signup', locals: {to: "track your #{crop.name} harvests" }
= render partial: 'shared/signin_signup', locals: { to: "track your #{crop.name} harvests" }

View File

@@ -3,7 +3,7 @@
- unless defined? max
- max = 0 # list all without "show all" toggle button
- display_crops.each do |c|
%li.crop-hierarchy{ class: max != 0 && @count >= max ? ['hide', 'toggle'] : []}
%li.crop-hierarchy{ class: max != 0 && @count >= max ? ['hide', 'toggle'] : [] }
= link_to c, c
- @count += 1
- if c.varieties.present?

View File

@@ -1,13 +1,9 @@
- cache crop do
= link_to |
image_tag( |
crop.default_photo ? crop.default_photo.thumbnail_url : 'placeholder_150.png', |
:alt => crop.name, |
:class => 'image-responsive crop-image' |
), |
crop, |
:rel => "popover", |
'data-trigger' => 'hover', |
'data-title' => crop.name, |
'data-content' => "#{ render :partial => 'crops/popover', :locals => { :crop => crop } }", |
'data-html' => true |
= link_to image_tag(crop.default_photo.present? ? crop.default_photo.thumbnail_url : 'placeholder_150.png',
alt: crop.name, class: 'image-responsive crop-image'),
crop.name,
rel: "popover",
'data-trigger': 'hover',
'data-title': crop.name,
'data-content': render(partial: 'crops/popover', locals: { crop: crop }),
'data-html': true

View File

@@ -1,9 +1,12 @@
.well
.row
.col-md-4
= link_to image_tag((crop.default_photo ? crop.default_photo.thumbnail_url : 'placeholder_150.png'), alt: '', class: 'img crop-image'), crop
= link_to image_tag((crop.default_photo ? crop.default_photo.thumbnail_url : 'placeholder_150.png'),
alt: '',
class: 'img crop-image'),
crop
.col-md-8
%h3{:style => 'padding-top: 0px; margin-top: 0px'}
%h3{ style: 'padding-top: 0px; margin-top: 0px' }
= link_to crop, crop
%p
@@ -16,6 +19,6 @@
by #{ENV['GROWSTUFF_SITE_NAME']} members
- if can? :create, Planting
= link_to 'Plant this', new_planting_path(:params => { crop_id: crop.id }), class: 'btn btn-primary'
= link_to 'Plant this', new_planting_path(params: { crop_id: crop.id }), class: 'btn btn-primary'
- if can? :create, Seed
= link_to 'Add seeds to stash', new_seed_path(:params => { crop_id: crop.id }), class: 'btn btn-primary'
= link_to 'Add seeds to stash', new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-primary'

View File

@@ -1,5 +1,5 @@
.row
- if !crop.photos.empty?
- unless crop.photos.empty?
- crop.photos.first(3).each do |p|
.col-md-4
= render partial: "photos/thumbnail", locals: { :photo => p }
= render partial: "photos/thumbnail", locals: { photo: p }

View File

@@ -3,13 +3,13 @@
- if crop.planted_from.empty?
not known.
- else
- planted_from = crop.planted_from.sort_by {|s, freq| freq }.reverse
= planted_from.map {|s, freq| "#{s} (#{freq})" }.join(", ")
- planted_from = crop.planted_from.sort_by { |_, freq| freq }.reverse
= planted_from.map { |s, freq| "#{s} (#{freq})" }.join(", ")
%p
%strong Plant in:
- if crop.sunniness.empty?
not known.
- else
- sunniness = crop.sunniness.sort_by {|s, freq| freq }.reverse
= sunniness.map {|s, freq| "#{s} (#{freq})" }.join(", ")
- sunniness = crop.sunniness.sort_by { |_, freq| freq }.reverse
= sunniness.map { |s, freq| "#{s} (#{freq})" }.join(", ")

View File

@@ -1,4 +1,4 @@
%h4 See who's planted #{ crop.name.pluralize }
%h4 See who's planted #{crop.name.pluralize}
- if crop.plantings.empty?
%p
Nobody has planted this crop yet.
@@ -17,5 +17,5 @@
- if current_member
%p= link_to "Plant #{crop.name}", new_planting_path(crop_id: crop.id)
- else
= render partial: 'shared/signin_signup', locals: {to: "track your #{crop.name} plantings" }
= render partial: 'shared/signin_signup', locals: { to: "track your #{crop.name} plantings" }

View File

@@ -1,6 +1,6 @@
%p
%small
- if crop.scientific_names.size > 0
- unless crop.scientific_names.empty?
%i
= crop.scientific_names.first.name
%br/

View File

@@ -8,9 +8,9 @@
%li
= sn.name
- if can? :edit, sn
= link_to 'Edit', edit_scientific_name_path(sn), { class: 'btn btn-default btn-xs' }
= link_to 'Edit', edit_scientific_name_path(sn), class: 'btn btn-default btn-xs'
- if can? :destroy, sn
= link_to 'Delete', sn, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs'
%p
- if can? :edit, crop
= link_to 'Add', new_scientific_name_path( crop_id: crop.id ), { class: 'btn btn-default btn-xs' }
= link_to 'Add', new_scientific_name_path(crop_id: crop.id), class: 'btn btn-default btn-xs'

View File

@@ -2,11 +2,13 @@
.crop-thumbnail
- if crop
- cache cache_key_for(Crop, crop.id) do
= link_to image_tag((crop.default_photo ? crop.default_photo.thumbnail_url : 'placeholder_150.png'), alt: crop.name, class: 'img'), crop
= link_to image_tag((crop.default_photo ? crop.default_photo.thumbnail_url : 'placeholder_150.png'),
alt: crop.name, class: 'img'),
crop
.cropinfo
.cropname
= link_to crop.name, crop
- if crop.scientific_names.size > 0
- unless crop.scientific_names.empty?
.scientificname
= crop.scientific_names.first.name
.plantingcount

View File

@@ -11,10 +11,10 @@
Varieties of #{crop.name}:
- max = 5
= render partial: 'hierarchy', locals: { display_crops:[ crop ], max: max }
= render partial: 'hierarchy', locals: { display_crops: [crop], max: max }
- if max != 0 && @count > max
= button_tag "Show all #{@count-1} varieties", class: 'btn btn-link toggle crop-hierarchy'
= button_tag "Show all #{@count - 1} varieties", class: 'btn btn-link toggle crop-hierarchy'
= button_tag "Show less varieties", class: 'btn btn-link toggle crop-hierarchy hide'
- if ! crop.parent and crop.varieties.empty?
- if !crop.parent && crop.varieties.empty?
%p None known.

View File

@@ -1,4 +1,4 @@
- if can? :edit, crop or can? :destroy, crop
- if can?(:edit, crop) || can?(:destroy, crop)
%h4 Crop wrangling
%p
You are a
@@ -6,6 +6,9 @@
%strong CROP WRANGLER
%p
- if can? :edit, crop
= link_to 'Edit crop', edit_crop_path(crop), { class: 'btn btn-default btn-xs' }
= link_to 'Edit crop', edit_crop_path(crop), class: 'btn btn-default btn-xs'
- if can? :destroy, crop
= link_to 'Delete crop', crop, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs'
= link_to 'Delete crop', crop,
method: :delete,
data: { confirm: 'Are you sure?' },
class: 'btn btn-default btn-xs'

View File

@@ -2,18 +2,29 @@
- if @crop.approval_status == "approved"
- if @crop.requester
%p Requested by #{link_to @crop.requester, @crop.requester} #{distance_of_time_in_words(@crop.created_at, Time.zone.now)} ago.
%p Approved by #{link_to @crop.creator, @crop.creator}.
%p
Requested by #{link_to @crop.requester, @crop.requester}
#{distance_of_time_in_words(@crop.created_at, Time.zone.now)} ago.
%p
Approved by #{link_to @crop.creator, @crop.creator}.
- else
%p Added by #{link_to @crop.creator, @crop.creator} #{distance_of_time_in_words(@crop.created_at, Time.zone.now)} ago.
%p
Added by #{link_to @crop.creator, @crop.creator}
#{distance_of_time_in_words(@crop.created_at, Time.zone.now)} ago.
- elsif @crop.approval_status == "pending"
.alert.alert-danger
%p Requested by #{link_to @crop.requester, @crop.requester} #{distance_of_time_in_words(@crop.created_at, Time.zone.now)} ago.
%p Status: #{@crop.approval_status}.
%p
Requested by #{link_to @crop.requester, @crop.requester}
#{distance_of_time_in_words(@crop.created_at, Time.zone.now)} ago.
%p
Status: #{@crop.approval_status}.
- elsif @crop.approval_status == "rejected"
.alert.alert-danger
%p Requested by #{link_to @crop.requester, @crop.requester} #{distance_of_time_in_words(@crop.created_at, Time.zone.now)} ago.
%p Status: #{@crop.approval_status} by #{link_to @crop.creator, @crop.creator}.
%p
Requested by #{link_to @crop.requester, @crop.requester}
#{distance_of_time_in_words(@crop.created_at, Time.zone.now)} ago.
%p
Status: #{@crop.approval_status} by #{link_to @crop.creator, @crop.creator}.
= render 'form'

View File

@@ -6,4 +6,4 @@
= link_to "crops database", crops_path
- cache cache_key_for(Crop) do
= render partial: "hierarchy", locals: { display_crops:@crops }
= render partial: "hierarchy", locals: { display_crops: @crops }

View File

@@ -15,7 +15,11 @@
= form_tag(crops_path, method: :get, class: 'form-inline', role: 'form') do
.form-group
= label_tag :sort, "Sort by:", class: 'sr-only'
= select_tag "sort", options_for_select({"Sort by popularity" => 'popular', "Sort alphabetically" => 'alpha'}, @sort || 'popular'), class: 'form-control'
= select_tag "sort",
options_for_select({ "Sort by popularity": 'popular',
"Sort alphabetically": 'alpha' },
@sort || 'popular'),
class: 'form-control'
= submit_tag "Show", class: 'btn btn-primary'
.pagination
@@ -28,7 +32,7 @@
- if can? :create, Crop
%div
= link_to 'New Crop', new_crop_path, { class: 'btn btn-primary'}
= link_to 'New Crop', new_crop_path, class: 'btn btn-primary'
.pagination
= will_paginate @paginated_crops

View File

@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
%rss{version: 2.0}
%rss{ version: 2.0 }
%channel
%title Recently added crops (#{ENV['GROWSTUFF_SITE_NAME']})
%link= crops_url
- @crops.each do |crop|
%item
%title= crop.name
%pubDate= crop.created_at.to_s(:rfc822)
%pubdate= crop.created_at.to_s(:rfc822)
%link= post_url(crop)
%guid= post_url(crop)

View File

@@ -1,14 +1,23 @@
- content_for :title, (can?(:wrangle, @crop) ? "New crop" : "Suggest a crop")
- unless can? :wrangler, @crop
%p Thanks for taking the time to suggest a crop! Our crop database is managed by volunteers, and we appreciate your help. Here are some things to consider when suggesting a new crop:
%p
Thanks for taking the time to suggest a crop! Our crop database is
managed by volunteers, and we appreciate your help. Here are some
things to consider when suggesting a new crop:
%ul
%li First, you might want to #{link_to 'search our crops', crops_search_path} to make sure we don't have it already, perhaps under an alternate name.
%li
First, you might want to #{link_to 'search our crops', crops_search_path}
to make sure we don't have it already, perhaps under an alternate name.
%li
The Growstuff database only contains edible crops. In future we hope to
support other crops, but for now, if your suggestion is not edible we
won't be able to add it.
%li The Growstuff database only contains edible crops. In future we hope to support other crops, but for now, if your suggestion is not edible we won't be able to add it.
%li At this time, we are only adding crops which have a Wikipedia page. If you want to add a specific variety of crop that doesn't have its own Wikipedia entry, please use the more general form of the crop instead and put the name of your variety in the notes/description.
%li
At this time, we are only adding crops which have a Wikipedia page. If you
want to add a specific variety of crop that doesn't have its own Wikipedia
entry, please use the more general form of the crop instead and put the name
of your variety in the notes/description.
= render 'form'

View File

@@ -3,7 +3,7 @@
%p Crops you have requested
%div.pagination
.pagination
= will_paginate @requested
.row
@@ -11,5 +11,5 @@
.col-md-2.six-across
= render partial: "thumbnail", locals: { crop: crop }
%div.pagination
.pagination
= will_paginate @requested

View File

@@ -9,7 +9,10 @@
= form_tag crops_search_path, method: :get, id: 'crop-search', class: 'form-inline' do
.form-group
= label_tag :term, "Search crops:", class: 'sr-only'
= text_field_tag 'term', nil, class: 'search-query input-medium form-control', :placeholder => 'Search crops', value: @term
= text_field_tag 'term', nil,
class: 'search-query input-medium form-control',
placeholder: 'Search crops',
value: @term
= submit_tag "Search", class: 'btn btn-primary'
- if @matches.empty?
@@ -25,7 +28,7 @@
.pagination
= will_paginate @paginated_matches
%div#paginated_matches
#paginated_matches
.row
- @paginated_matches.each do |c|
.col-md-2.six-across

View File

@@ -19,20 +19,23 @@
= link_to "Harvest this", new_harvest_path(crop_id: @crop.id), class: 'btn btn-default'
- if can? :create, Seed
= link_to 'Add seeds to stash', new_seed_path(:params => { crop_id: @crop.id }), class: 'btn btn-default'
= link_to 'Add seeds to stash', new_seed_path(params: { crop_id: @crop.id }), class: 'btn btn-default'
- if member_signed_in?
= display_seed_availability(@current_member, @crop)
= link_to "View your seeds", seeds_by_owner_path(:owner => current_member.slug)
= link_to "View your seeds", seeds_by_owner_path(owner: current_member.slug)
.row
.col-md-9
- unless current_member
Learn how to grow #{ @crop.name.pluralize } from growers around the world. #{ ENV['GROWSTUFF_SITE_NAME'] } has tips and advice from real-life growers, including when to plant #{ @crop.name.pluralize }, how to harvest #{ @crop.name.pluralize }, and more.
Learn how to grow #{@crop.name.pluralize} from growers around the world.
#{ENV['GROWSTUFF_SITE_NAME']} has tips and advice from real-life growers,
including when to plant #{@crop.name.pluralize}, how to harvest
#{@crop.name.pluralize}, and more.
= render partial: 'photos', locals: { crop: @crop }
%h2
- if @crop.plantings.size > 0
- if !@crop.plantings.empty?
= @crop.name.titleize
has been planted
= pluralize(@crop.plantings.size, "time")
@@ -43,7 +46,7 @@
%h2
Sunniness Chart
%div#sunchart
#sunchart
%h2
Crop Map
@@ -52,37 +55,36 @@
- if current_member && current_member.location.blank?
= link_to "Set your location.", edit_member_registration_path
#cropmap
%div#cropmap
%a{:name => 'posts'}
%h2 What people are saying about #{ @crop.name.pluralize }
%a{ name: 'posts' }
%h2 What people are saying about #{@crop.name.pluralize}
- if @posts.empty?
%p
Nobody has posted about #{ @crop.name.pluralize } yet.
Nobody has posted about #{@crop.name.pluralize} yet.
%p
- if can? :create, Post
= link_to "Post something", new_post_path, class: 'btn btn-default'
- else
= render partial: "shared/signin_signup", locals: {to: "post your tips and experiences growing #{ @crop.name.pluralize }" }
= render partial: "shared/signin_signup",
locals: { to: "post your tips and experiences growing #{@crop.name.pluralize}" }
- else
.pagination
= page_entries_info @posts
= will_paginate @posts, :params => {:anchor => "posts"}
= will_paginate @posts, params: { anchor: "posts" }
- @posts.each do |post|
= render partial: "posts/single", locals: { post: post, subject: true }
.pagination
= page_entries_info @posts
= will_paginate @posts, :params => {:anchor => "posts"}
= will_paginate @posts, params: { anchor: "posts" }
.col-md-3
= render partial: 'wrangle', locals: { crop: @crop }
%h4 How to grow #{ @crop.name.pluralize }
%h4 How to grow #{@crop.name.pluralize}
= render partial: 'grown_for', locals: { crop: @crop }
= render partial: 'planting_advice', locals: { crop: @crop }
@@ -90,7 +92,7 @@
= render partial: 'scientific_names', locals: { crop: @crop }
= render partial: 'alternate_names', locals: { crop: @crop }
%h4 #{ @crop.name.capitalize } varieties
%h4 #{@crop.name.capitalize} varieties
= render partial: 'varieties', locals: { crop: @crop }
= render partial: 'plantings', locals: { crop: @crop }
@@ -98,13 +100,21 @@
= render partial: 'find_seeds', locals: { crop: @crop }
%h4 Learn more about #{ @crop.name.pluralize }
%h4 Learn more about #{@crop.name.pluralize}
%ul
%li= link_to 'Wikipedia (English)', @crop.en_wikipedia_url, target: "_blank", rel: "noopener noreferrer"
%li
= link_to "OpenFarm - Growing guide", "https://openfarm.cc/en/crops/#{URI.escape @crop.name}", target: "_blank", rel: "noopener noreferrer"
= link_to "OpenFarm - Growing guide", "https://openfarm.cc/en/crops/#{URI.escape @crop.name}",
target: "_blank",
rel: "noopener noreferrer"
%li
= link_to "Gardenate - Planting reminders", "http://www.gardenate.com/plant/#{URI.escape @crop.name}", target: "_blank", rel: "noopener noreferrer"
= link_to "Gardenate - Planting reminders", "http://www.gardenate.com/plant/#{URI.escape @crop.name}",
target: "_blank", rel: "noopener noreferrer"
- if current_member && current_member.location
%li
= link_to "Google", "http://www.google.com/search?q=#{URI.escape ["Growing", @crop.name, current_member.location].join(" ")}", target: "_blank", rel: "noopener noreferrer"
= link_to "Google",
'http://www.google.com/search?q=' + URI.escape(['Growing',
@crop.name,
current_member.location].join(' ')),
target: "_blank",
rel: "noopener noreferrer"

View File

@@ -17,12 +17,12 @@
.tabbable
%ul.nav.nav-tabs
%li{ class: @approval_status.blank? ? 'active' : ''}
%li{ class: @approval_status.blank? ? 'active' : '' }
= link_to "Recently added", wrangle_crops_path
%li{ class: @approval_status == "pending" ? 'active' : ''}
= link_to "Pending approval", wrangle_crops_path(:approval_status => "pending")
%li{ class: @approval_status == "rejected" ? 'active' : ''}
= link_to "Rejected", wrangle_crops_path(:approval_status => "rejected")
%li{ class: @approval_status == "pending" ? 'active' : '' }
= link_to "Pending approval", wrangle_crops_path(approval_status: "pending")
%li{ class: @approval_status == "rejected" ? 'active' : '' }
= link_to "Rejected", wrangle_crops_path(approval_status: "rejected")
%h2
- if @approval_status == "pending"
@@ -37,7 +37,8 @@
= page_entries_info @crops
= will_paginate @crops
%table{ class: "table table-striped", id: @approval_status.blank? ? 'recently-added-crops' : "#{@approval_status}-crops"}
%table{ class: "table table-striped",
id: @approval_status.blank? ? 'recently-added-crops' : "#{@approval_status}-crops" }
%tr
%th System name
%th English Wikipedia URL

View File

@@ -248,9 +248,9 @@ describe Crop do
it 'counts each plant_part value' do
@fruit = FactoryGirl.create(:plant_part)
@seed = FactoryGirl.create(:plant_part)
@root = FactoryGirl.create(:plant_part)
@bulb = FactoryGirl.create(:plant_part)
@seed = FactoryGirl.create(:plant_part, name: 'seed')
@root = FactoryGirl.create(:plant_part, name: 'root')
@bulb = FactoryGirl.create(:plant_part, name: 'bulb')
@harvest1 = FactoryGirl.create(:harvest,
crop: crop,
plant_part: @fruit
@@ -267,7 +267,9 @@ describe Crop do
crop: crop,
plant_part: @root
)
crop.popular_plant_parts.should == { @fruit => 2, @seed => 1, @root => 1 }
crop.popular_plant_parts.should == { [@fruit.id, @fruit.name] => 2,
[@seed.id, @seed.name] => 1,
[@root.id, @root.name] => 1 }
end
end