In Gmail, go to Settings (under the gear icon) and under the General tab find the section that says "Keyboard Shortcuts". Set them to "on".
- New Tab:
Command + T
this is useful if you find yourself using your mouse to click the new tab button - Close Tab:
Command + W
now you won't have a billion tabs open...or not. - Close Chrome:
Command + Q
this shortcut works in basically every application - not just Chrome - Next Tab:
Command + Option + Right Arrow
- Previous Tab:
Command + Option + Left Arrow
- Find:
Command + F
- Go Back:
Command + Left Arrow
- Copy:
Command + C
- Cut:
Command + X
- Switch to recently used application:
Command + Tab
- See list of recently used applications:
Command + Tab (Release tab and continue holding command. Select an app with left / right arrow)
- Next window in current application:
Command + ~
- Open Spotlight:
Command + Space
heroku create <YOUR APP NAME>
heroku config:add BUNDLE_WITHOUT=development:test
In locomotive.rb, add the following:
config.hosting = {
:target => :heroku,
In my humble opinion, Rails is missing a tool for parsing forms on the backend. Currently the process looks something like this:
# new.html.erb
<%= form_for @trip do |trip_builder| %>
<div class="field">
<%= trip_builder.label :miles %>
<%= trip_builder.text_field :miles, placeholder: '50 miles' %>
</div>
<% end %>
- wysiwyg source code: https://github.com/Voog/wysihtml
- Example usage: https://github.com/LaunchPadLab/fuel (note that this is a Rails Engine, so the implementation is more complex and just plain different than it would be in a regular Rails app).
Inheritance | |
=== | |
Using inheritance in Ruby is extremely powerful and can greatly reduce complexity in the code. In this blog post, I'm going to walk through a use case for inheritance in the context of Ruby on Rails. | |
Example Use Case: Form Parsing | |
--- | |
We have an apartment listings website. Users can search for apartments in their area and refine the search with filters like # of bedrooms, min and max price, and lease start date. |
Using inheritance in Ruby is extremely powerful and can greatly reduce complexity in the code. In this blog post, I'm going to walk through a use case for inheritance in the context of Ruby on Rails.
We have an apartment listings website. Users can search for apartments in their area and refine the search with filters like # of bedrooms, min and max price, and lease start date.
Using inheritance in Ruby is extremely powerful and can greatly reduce complexity in your code. In this blog post, I show you how to dry up your code with Plain Ole' Ruby Objects (PORO's) that leverage inheritance.
Let's say we have an apartment listings website. Users can search for apartments in their area and refine the search with filters like # of bedrooms, max price, and lease start date.
User Chooses Number of Bedrooms (images courtesy of apartmentlist.com)
class NestedAttributesUniquenessValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, items) | |
items = items.reject(&:_destroy) # let's ignore the items to be destroyed here | |
unless items.map(&options[:field]).to_a.uniq.size == items.size | |
record.errors[attribute] << "must be unique" | |
field = options[:field] | |
values = items.map {|item| item.send(field) } | |
duplicates = items.find_all {|item| values.count(item.send(field)) > 1 && item.id.nil? } | |
duplicates.each { |obj| obj.errors[field] << "has already been taken" } | |
end |