I am using Mongodb with ROR . This is the command:
<%= render partial: "show", collection: @h %>
Where @h
is
@h=[
{"folder"=>"Default", "weight"=>"100.0", "stocks"=>[
{"id"=>"id1", "name"=>"Ajanta Pharma Ltd.", "weight"=>"57.0"},
{"id"=>"id11", "name"=>"Avanti Feeds Ltd.", "weight"=>"5.1"},
{"id"=>"id34", "name"=>"MPS Ltd.", "weight"=>"2.5"},
{"id"=>"id89", "name"=>"Poly Medicure Ltd.", "weight"=>"3.7"}]},
{"folder"=>"low margin", "weight"=>"0.0", "stocks"=>[
]},
{"folder"=>"fjf", "weight"=>"0.0", "stocks"=>[
]}
]
Suppose my _show.erb
is this
i am line
The output i am getting is i am linei am linei am line
actually no. of times the folder in @h
* content in _show.erb
If I change @h
to this
@h=[
{"folder"=>"Default", "weight"=>"100.0", "stocks"=>[
{"id"=>"id1", "name"=>"Ajanta Pharma Ltd.", "weight"=>"57.0"},
{"id"=>"id11", "name"=>"Avanti Feeds Ltd.", "weight"=>"5.1"},
{"id"=>"id34", "name"=>"MPS Ltd.", "weight"=>"2.5"},
{"id"=>"id89", "name"=>"Poly Medicure Ltd.", "weight"=>"3.7"}]},
{"folder"=>"low margin", "weight"=>"0.0", "stocks"=>[
]}`
]
Then it gives i am linei am line
as folder are 2 why it is happening as only want one time output irrespective of no. of folders . How can I do that?