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
| class Court < ActiveRecord::Base | |
| validates_format_of :slug, with: /\A[a-zA-Z-]+\z/, allow_nil: true | |
| extend FriendlyId | |
| friendly_id :slug_candidates, use: [:slugged, :history, :finders] | |
| private | |
| def slug_candidates | |
| candidates = [:name] |
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
| user = User.first | |
| user.avatar.file.exists? |
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
| class AvatarUploader < CarrierWave::Uploader::Base | |
| storage :fog | |
| end |
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
| class User < ActiveRecord::Base | |
| mount_uploader :avatar, AvatarUploader | |
| end |
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
| !.*/(\.[^/]*|vendor/.*|doc|rails_root|CVS|log|data_dump|build|_darcs|pkg |_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)? |bundle))$ |
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
| #paperclip.rb in config/initializers | |
| Paperclip.interpolates :created_at do |attachment, style| | |
| attachment.instance.created_at.to_i | |
| end | |
| # path in your model will look like this | |
| # :path => ":attachment/gallery/:id/:created_at/:style.:extension" |
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
| certificate = OpenSSL::X509::Certificate.new(File.read("#{Rails.root}/certificate.pem")) | |
| #public key from certificate | |
| public_key = cert.public_key | |
| #or public key from file | |
| public_key = OpenSSL::PKey::RSA.new("#{Rails.root}/public_key.pem") | |
| clear_text = public_key.public_decrypt(encrypted_text) |
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 file http://github.com/qoobaa/s3.git belongs to config/initializers/ | |
| In your Model: | |
| has_attached_file :picture, | |
| :styles => { | |
| :banner => '475x233#', | |
| :thumbnail => '111x50#' | |
| }, | |
| :storage => :s3, |
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
| $('.it') | |
| .bind('enqueued', function() {...}) | |
| .bind('running', function() {...}) | |
| .bind('passed', function() {...}) | |
| .bind('failed', function(e, reason) {...}) | |
| $(Screw) | |
| .bind('loading', function() {...}) | |
| .bind('loaded', function() {...}) | |
| .bind('before', function() {...}) |
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
| Screw.Matchers["be_even"] = { | |
| match: function(expected, actual) { | |
| return actual % 2 == 0; | |
| }, | |
| failure_message: function(expected, actual, not) { | |
| return 'expected ' + $.print(actual) + (not ? ' not' : '') + ' to be even'; | |
| } | |
| } |
NewerOlder