-
The new rake task assets:clean removes precompiled assets. [fxn]
-
Application and plugin generation run bundle install unless
--skip-gemfile
or--skip-bundle
. [fxn] -
Fixed database tasks for jdbc* adapters #jruby [Rashmi Yadav]
-
Template generation for jdbcpostgresql #jruby [Vishnu Atrai]
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
require "time" | |
require "date" | |
class Date | |
def to_time | |
Time.local(year, month, day) | |
end | |
end | |
class Time |
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 AssetHeaders | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
request = Rack::Request.new(env) | |
response = @app.call(env) | |
if request.path =~ /^\/assets\// | |
# there maybe a better way to add headers |
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
$('#products').append('<%= j render(@products) %>'); | |
<% if @products.next_page %> | |
$('.pagination').replaceWith('<%= j will_paginate(@products) %>'); | |
<% else %> | |
$('.pagination').remove(); | |
<% end %> |
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
# Examples of Nesting Associated Attributes | |
# This is a look at the various ways to set associated attributes through | |
# nested parameters. For example, let's say Project has_many :tasks and | |
# we want to update the tasks the same time we edit a project. There are | |
# several ways this interface could be handled, and here are a few. | |
# | |
# For these examples, we're trying to create two new tasks and update an | |
# existing task (with id 3) through a project. | |
# Approach 1 |
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
require "rubygems" | |
require "octokit" # gem install octokit | |
1.upto(5) do |page| | |
Octokit.repositories("railscasts", page: page, per_page: 100).each do |repo| | |
system "git clone git://github.com/railscasts/#{repo.name}" | |
end | |
end |
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
# Mimic Mac OS X Finder's sort by name. | |
class Array | |
def finder_sort | |
sort_by do |str| | |
punctuation = %w[` ^ _ - , ; ! ? ' " ( ) [ ] { } @ *] + ['\\'] + %w[& # % + < = > | ~ $] | |
str.to_s.gsub(/\d+|[^a-z\s]/i) do |match| | |
if punctuation.include? match | |
"1".rjust(200 - punctuation.index(match), "0") | |
elsif match =~ /^0+$/ # make an exception for zeros | |
"1".rjust(101, "0") |
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
# This sets up both a memory store and file system store for Shrine file uploads. | |
# We use the memory store by default but in cases where you want to test actual | |
# file uploads you can enable it with `file_upload: true` on a per example basis | |
require "shrine/storage/memory" | |
require "shrine/storage/file_system" | |
# We use a delegator to swap out the storage dynamically | |
# since the storage hash is duplicated for each uploader | |
class Shrine::Storage::Dynamic < SimpleDelegator | |
def initialize(initial, storages) |
First install the required gems:
gem install octokit awesomeprint rainbow
Then run it to extract all of your open GitHub issues into files (with comments).
ruby my-gh-issues.rb
These are some of my (Ryan Bates) favorite gems to use for various tasks:
- JavaScript: jQuery with jquery-rails
- Pagination: Kaminari
- Testing: RSpec, Cucumber and Capybara
- Factories: Factory Girl
- Authentication: Nifty Generators and Omniauth
- Authorization: CanCan
- File Attachments: Carrierwave
- HTML/XML Parsing: Nokogiri