-
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]
generators = [] | |
puts 'Spinning up a new app, captain!' | |
devise = yes?('Use Devise? (yes/no)') | |
jquery = yes?('Use jQuery? (yes/no)') | |
jquery_ui = yes?('Use jQuery UI? (yes/no)') if jquery | |
mongoid = yes?('Use mongoid? (yes/no)') | |
haml = yes?('Use haml? (yes/no)') | |
rspec = yes?('Use Rspec? (yes/no)') |
source :rubygems | |
gem 'rails', '3.0.3' | |
gem 'mongo', '1.1.5' | |
gem 'bson', '1.1.5' | |
gem 'bson_ext', '1.1.5' | |
gem 'mongoid', '2.0.0.beta.20' | |
gem 'carrierwave' |
defaults: &defaults | |
host: localhost | |
# slaves: | |
# - host: slave1.local | |
# port: 27018 | |
# - host: slave2.local | |
# port: 27019 | |
development: | |
<<: *defaults |
Note that this validation runs both after the file is uploaded and after CarrierWave has processed the image. If your base uploader includes a filter to resize the image then the validation will be run against the resized image, not the original one that was uploaded. If this causes a problem for you, then you should avoid using a resizing filter on the base uploader and put any specific size requirements in a version instead.
So instead of this:
require 'carrierwave/processing/mini_magick'
def error_messages_for(*objects) | |
options = objects.extract_options! | |
options[:header_message] ||= I18n.t(:"activerecord.errors.header", :default => "Invalid Fields") | |
options[:message] ||= I18n.t(:"activerecord.errors.message", :default => "Correct the following errors and try again.") | |
messages = objects.compact.map { |o| o.errors.full_messages }.flatten | |
unless messages.empty? | |
content_tag(:div, :class => "error_messages") do | |
list_items = messages.map { |msg| content_tag(:li, msg) } | |
content_tag(:h2, options[:header_message]) + content_tag(:p, options[:message]) + content_tag(:ul, list_items.join.html_safe) | |
end |
class Attachment < ActiveRecord::Base | |
belongs_to :post | |
mount_uploader :filename, PostAttachmentUploader | |
VIDEO_FORMATS = %W{ogv mp4 webm} | |
PREVIEW_FORMAT = "jpeg" | |
before_save :set_metas | |
after_create :start_encoding!, :if => :video? | |
By default, Rails applications build URLs based on the primary key -- the id
column from the database. Imagine we have a Person
model and associated controller. We have a person record for Bob Martin
that has id
number 6
. The URL for his show page would be:
/people/6
But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6
here, is called the "slug". Let's look at a few ways to implement better slugs.
# encoding: utf-8 | |
class AvatarUploader < CarrierWave::Uploader::Base | |
include CarrierWave::MiniMagick | |
# Choose what kind of storage to use for this uploader: | |
storage :file | |
# Override the directory where uploaded files will be stored. |
upstream app { | |
server unix:/srv/app/current/tmp/sockets/unicorn.sock fail_timeout=0; | |
} | |
server { | |
listen 80; | |
server_name www.app.com; | |
rewrite ^/(.*) http://app.com/$1 permanent; | |
} | |
server { |