Created
March 21, 2012 20:37
-
-
Save jumph4x/2152664 to your computer and use it in GitHub Desktop.
manual rate_hash iteration for spree
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
#this is what Order#rate_hash outputs, roughly | |
sample_rate_hash = [{:id => 4, :name => 'ShippingMethod', :price => 24.55}] | |
# we take the array of hashes and for each one we create an HTML <option>, we show the user the name and the price, for value we store the shipping_method_id | |
# then we join all the html options into one string | |
# then we mark the string as safe for frontend | |
options = sample_rate_hash.map{|rate| content_tag(:option, "#{rate[:name]} #{rate[:price]}", :value => rate[:shipping_method_id])}.join.html_safe | |
# then we simply give that to select | |
select_tag :order, options |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment