Rails Inflector:
http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html
if model name = "UserAccountHistory " ,table name = "user_account_histories"
"user_History".tableize # user_histories
"user_history".pluralize # user_Histories
"user_account_history".camelize # UserAccountHistory
TIMESTAMP
Time.now.strftime("%Y%m%d%H%M%S")
string replace
a = "sonu is a good boy"
a.gsub(" ","") => sonuisagoodboy"
MODEL
Available transformation : t.references, t.timestamps,, t.remove_timestamps, t.remove_belongs_to
http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/Table.html
belongs_to :singular_name_of_table
has_many :plural_name_of_table
HELPERS
number helpers: http://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html
numer_to_currency(234343) => $23,53,24
BEFORE TESTING:
rake db:test:prepare
thinking_sphinx
rake thinking_sphinx:index
rake thinking_sphinx:start/stop
rake thinking_sphinx: rebuild
No comments:
Post a Comment