1.2 is broken/has some strange bugs, just upgrade and save yourself some headaches…
sudo gem update –system is broken in 1.2 too, so lets do it by hand…
sudo gem install rubygems-update sudo update_rubygems
1.2 is broken/has some strange bugs, just upgrade and save yourself some headaches…
sudo gem update –system is broken in 1.2 too, so lets do it by hand…
sudo gem install rubygems-update sudo update_rubygems
With the clear_empty_attributes plugin, all empty string worries are gone!
WHERE field IS NULL OR field = '')unless field.blank? (opposed to only if field)filled or '' and suddenly they are nil:allow_blank=>trueNULL better & faster than '' (especially when using LIKE)Install
script/plugin install git://github.com/grosser/clear_empty_attributes.git
Now all empty strings will be saves as NULL.
Migrate
To take care of all other/old models we have to run a migration.
Remove any blank strings/texts from your Models:
rake clear_empty_attributes:clear_all_blank_strings MODELS=User,Movie,...
Tired of all the erb whitespace and those <%-end-%> madness ?
Switch to HAML for emails!!
How to?
Example
==Hello #{@user},
Your order has been completed on #{Time.now}.
You may now access the bought items:
==
- content = capture do
- for item in @order.items
- if item.shipping?
We will send it to you soon.
- else
please download it here:
==#{item.orderable} -- #{polymorphic_url(item.orderable)}
==
=content.gsub(/^( )*/,'')
==
=mail_signature
Problem
Solution
Magic
Install
http://github.com/grosser/autolang
Copy autolang.rake OR checkout into lib/tasks(if you are using rails, otherwise place it where rake can find it)
(Non-ruby?: install ruby + rubygems + rake-gem)
Usage
rake autolang:translate L=es POT_FILE=x.pot
Example Output
(commandline output, translations are written to "es.po")
Translating...
register
registro
--------------------------------------------------------------------------------
login
inicio de sesión
--------------------------------------------------------------------------------
Your DVD is being built and will be finished soon.
Su DVD se está construyendo y será terminado pronto.
--------------------------------------------------------------------------------
Invitation sent to %{email}
Invitación enviada a %{email}
....
Our admins are always data-greedy, so i provided a method that lets them get detailed data on any search result they like. Be careful to not let normal users access this (hide email addresses etc).
Installation
Usage
format.csv do
#collect data
keys = current_model.new.attributes.keys.sort
csv_string = FasterCSV.generate do |csv|
csv << keys
@current_objects.each do |record|
csv << record.attributes.sort_by{|k,v|k}.map{|arr|arr[1]}
end
end
#send data
filename = current_model.to_s.downcase.gsub(/[^0-9a-z]/, "_") + ".csv"
send_data(csv_string,
:type => 'text/csv; charset=utf-8; header=present',
:filename => filename
)
end