This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| class ApplicationController < ActionController::Base | |
| ... | |
| # FORCE to implement content_for in controller | |
| def view_context | |
| super.tap do |view| | |
| (@_content_for || {}).each do |name,content| | |
| view.content_for name, content | |
| end | |
| end | |
| end |
| class ApplicationController < ActionController::Base | |
| # ... | |
| unless Rails.application.config.consider_all_requests_local | |
| rescue_from Exception, with: lambda { |exception| render_error 500, exception } | |
| rescue_from ActionController::RoutingError, ActionController::UnknownController, ::AbstractController::ActionNotFound, ActiveRecord::RecordNotFound, with: lambda { |exception| render_error 404, exception } | |
| end | |
| private | |
| def render_error(status, exception) |
| class ModelName | |
| # declare papaerclip :avatar file | |
| # ... | |
| after_validation :avatar_reverted? | |
| def avatar_reverted? | |
| unless self.errors[:avatar_file_size].blank? or self.errors[:avatar_content_type].blank? | |
| self.avatar.instance_write(:file_name, self.avatar_file_name_was) | |
| self.avatar.instance_write(:file_size, self.avatar_file_size_was) | |
| self.avatar.instance_write(:content_type, self.avatar_content_type_was) |
| namespace :remote_rake do | |
| desc 'Run a task on a remote server.' | |
| # run like: cap remote_rake:invoke task="db:reset" | |
| task :invoke do | |
| run("cd #{deploy_to}/current && bundle exec rake #{ENV['task']} RAILS_ENV=#{rails_env}") | |
| end | |
| end |
| <!-- /app/views/admin/users/new_invitiations.html.erb --> | |
| <h2>Send invitation</h2> | |
| <%= form_for @user, :url => send_invitation_admin_users_path do |f| %> | |
| <table style='width: 50%'> | |
| <tr> | |
| <td><%= f.label :first_name %></td> | |
| <td><%= f.text_field :first_name %></td> |
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
| 'use strict'; | |
| function createPersonRepository() { | |
| const persons = [{ | |
| id: 1, | |
| name: 'Archimedes' | |
| }, { | |
| id: 2, | |
| name: 'Plato' | |
| }, { |
##Reactive System Design Links
#Articles and Papers