Magical path/url helpers
Where do those magical path/url helpers pull the values together? I found this interesting.
b /Users/davidvezzani/.rvm/gems/ruby-1.9.3-p194@rails328/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:222
My journey through Ruby/Rails and many associated tools that can help build robust Rails applications.
Magical path/url helpers
Where do those magical path/url helpers pull the values together? I found this interesting.
b /Users/davidvezzani/.rvm/gems/ruby-1.9.3-p194@rails328/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:222
Convert Haml to ERB
http://makandracards.com/makandra/544-convert-haml-to-erbThere are plenty of tools for converting from ERB to HAML. I'm not ready to drink the kool aid, even though HAML has been around forever and there seems to be a great following.
script/plugin install http://github.com/cgoddard/haml2erb.git hamls = Dir["app/views/**/*.haml"] - ['app/views/layouts/screen.html.haml']; hamls.each do |haml| puts haml erb = haml.sub(/\.haml$/, '.erb') File.open(erb, 'w') do |file| file.write Haml2Erb.convert(File.read(haml)) end end
There are plenty of hits on how you can tell Rails to automatically generate HAML, but I still love using ERB. Taking a guess with the pattern for automatically generating HAML, it appears I got it right.
Somehow, Comfortable Mexican Sofa buries the setting for automatically generating HAML in some dark corner of it's codebase. Setting the preference in config/application.rb takes precedence, thank goodness.
config.generators do |g| # g.template_engine :haml g.template_engine :erb end
Ucpathpersonjob.sum(:emplrecord)
Ucpathpersonjob.where("emplrecord < 7000").sum(:emplrecord)
sum_value = 0 Expense.all.each do |record| sum_value = sum_value + record.price end
1 + 2 + 3 + 4 + 5 + 6 + 67 + 7 + 8 + 8 + 9 + 90 + 23 => 233
[1, 2, 3, 4, 5, 6, 67, 7, 8, 8, 9, 90, 23].inject(0){|a,b| b += a} => 233
Expense.all.inject(0){|expense, sum| sum += expense.price}