This file contains 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
# Consider this common pattern... | |
if (user = User.find params[:id]) | |
user.profile_viewed | |
end | |
# Would be a bit less awkward if... | |
with User.find params[:id] do |user| | |
user.profile_viewed |
This file contains 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
// I often do stuff like (coffeescript): | |
// | |
// class @Forms.Select extends React.Component | |
// | |
// Which, often requires an ugly @Forms ||= {} somewhere, or this will | |
// explode. Now, I know there's better ways to do this, and CommonJS has | |
// its nifty resource stuff, but I am old and stuck in my ways and stuff. | |
// | |
// With this snippet (if you're in rails, you can include it in application.js | |
// before your components dir), you can write (again, coffee): |
This file contains 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 ApplicationRecord << ActiveRecord::Base | |
#... | |
after_validation :log_validation_errors | |
private | |
def log_validation_errors | |
Rails.logger.tagged self.class.name do | |
if self.errors.empty? |
OlderNewer