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
| # polymorphic_select_tag @item, :owner, Post.all(:order=>'created_at DESC').collect{|b| #[b.title, [Post, b.id]]} | |
| def polymorphic_select_tag(object, field, option_array=[], options={}, html_options={}) | |
| option_tags = "<option #{'selected="selected"' if (object.try(field) == nil)}/>" + | |
| option_array.map do |tuple| | |
| "<option value='#{tuple[1][0]}-#{tuple[1][1]}' #{'selected="selected"' if ((object.try(field).try(:id).to_s == tuple[1][1].to_s && object.try(field).try(:type).to_s == tuple[1][0].to_s) rescue false)}>#{tuple[0]}</option>" | |
| end.to_s | |
| prefix = options[:prefix] || '' | |
| object_id = object.id |
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
| SHOW CREATE TABLE old_table; | |
| INSERT INTO new_table SELECT DISTINCT * FROM old_table; | |
| DROP TABLE old_table; | |
| RENAME TABLE new_table TO old_table; |
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
| log/*.log | |
| .DS_Store | |
| public/cache/**/* | |
| public/system/**/* | |
| config/database.yml | |
| config/*.sphinx.conf | |
| config/s3_credentials.yml | |
| *~ | |
| *.cache | |
| *.pid |
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
| # generate random sequence | |
| #SecureRandom also has methods for: base64, hex, bytes, random_number | |
| #see: http://api.rubyonrails.org/classes/ActiveSupport/SecureRandom.html | |
| require 'active_support/secure_random' | |
| ActiveSupport::SecureRandom.hex(16) | |
| # outputs: 6dc19d21e958e04645cddadb96e9c927 |
NewerOlder