# You should have the 'rails' RubyGem installed
$ rails new myapp
$ cdmyapp
Gemfile
in the application root to determine the gems you require for your application to start. This Gemfile
is processed by the Bundler gem, which then installs all your dependencies. It can even install all the dependencies locally to your application so that it doesn't depend on the system gems.
More information: Bundler homepage
Bundler
and Gemfile
makes freezing your Rails application easy as pie with the new dedicated bun
dle
command. If you want to bundle straight from the Git repository, you can pass the --edge
flag:
$ rails new myapp --edge
If you have a local checkout of the Rails repository and want to generate an application using that, you can pass the --dev
flag:
$ ruby /path/to/rails/railties/bin/rails new myapp --dev
Gemfile
to manage installed gems.
params.
permit(:title, :text)
).
●Routing concerns (commit) - In the routing DSL, factor out common subroutes (comments
from /p
osts/1/comments
and /videos/1/c
omments
).
●ActionController::Live (commit) - Stream JSON with response.st
ream
.
●Declarative ETags (commit) - Add controller-level etag additions that will be part of the action etag computation.
●Russian doll caching (commit) - Cache nested fragments of views. Each fragment expires based on a set of dependencies (a cache key). The cache key is usually a template version number and a model object.
●Turbolinks (commit) - Serve only one initial HTML page. When the user navigates to another page, use pushState to update the URL and use AJAX to update the title and body.
●Decouple ActionView from ActionController (commit) - ActionView was decoupled from ActionPack and will be moved to a separated gem in Rails 4.1.
●Do not depend on ActiveModel (commit) - ActionPack no longer depends on ActiveModel.
A
ctiveModel::Model
, a mixin to make normal Ruby objects to work with ActionPack out of box (ex. for form_for
)
●New scope API (commit) - Scopes must always use callables.
●Schema cache dump (commit) - To improve Rails boot time, instead of loading the schema directly from the database, load the schema from a dump file.
●Support for specifying transaction isolation level (commit) - Choose whether repeatable reads or improved performance (less locking) is more important.
●Dalli (commit) - Use Dalli memcache client for the memcache store.
●Notifications start & finish (commit) - Active Support instrumentation reports start and finish notifications to subscribers.
●Thread safe by default (commit) - Rails can run in threaded app servers without additional configuration.
Check that the gems you are using are threadsafe.
●PATCH verb (commit) - In Rails, PATCH replaces PUT. PATCH is used for partial updates of resources.
raw
orhtml_safe
is called.
●New security headers (commit) - Rails sends the following headers with every HTTP request: X-
Frame-Options
(prevents clickjacking by forbidding the browser from embedding the page in a frame), X-XSS-Protection
(asks the browser to halt script injection) and X-Content-Type-Option
s
(prevents the browser from opening a jpeg as an exe).
Gemfile
to bring the functionality back.
●Hash-based & Dynamic finder methods (GitHub)
●Mass assignment protection in Active Record models (GitHub, Pull Request)
●ActiveRecord::SessionStore (GitHub, Pull Request)
●Active Record Observers (GitHub, Commit)
●Active Resource (GitHub, Pull Request, Blog)
●Action Caching (GitHub, Pull Request)
●Page Caching (GitHub, Pull Request)
●Sprockets (GitHub)
●Performance tests (GitHub, Pull Request)
test/models
, test/helpers
, test/controllers
, and test/mailers
. Corresponding rake tasks added as well. (Pull Request)
Your app's executables now live in the bin/
directory. Run rak
e rails:update:bin
to get bin/b
undle
, bin/rails
, and bin/rake
.
Threadsafe on by default
Ability to use a custom builder by passing --builder
(or-b
) to
r
ails new
has been removed. Consider using application templates
instead. (Pull Request)
config.threadsafe!
is deprecated in favor of config.eager_load
which provides a more fine grained control on what is eager loaded.
Rails::Plugin
has gone. Instead of adding plugins to vendor/pl
ugins
use gems or bundler with path or git dependencies.
ActiveModel::ForbiddenAttri
butesProtection
, a simple module to protect attributes from mass assignment when non-permitted attributes are passed.
Added ActiveModel::Model
, a mixin to make Ruby objects work with Action Pack out of box.
memcache-cli
ent
gem with dalli
inActiveSuppor
t::Cache::MemCacheStore
.
Optimize ActiveSupport::Cache::
Entry
to reduce memory and processing overhead.
Inflections can now be defined per locale. singularize
and plu
ralize
accept locale as an extra argument.
Object#try
will now return nil instead of raise a NoMethodError if the receiving object does not implement the method, but you can still get the old behavior by using the new Object#try!
.
String#to_date
now raises Argum
entError: invalid date
instead of NoMethodError: undefined met
hod 'div' for nil:NilClass
when given an invalid date. It is now the same as Date.parse
, and it accepts more invalid dates than 3.x, such as:
# ActiveSupport 3.x
"asdf".to_date # => NoMethodError: undefined method `div' for nil:NilClass
"333".to_date # => NoMethodError: undefined method `div' for nil:NilClass
# ActiveSupport 4
"asdf".to_date # => ArgumentError: invalid date
"333".to_date # => Fri, 29 Nov 2013
NoMethodError: undefined method `div' for nil:NilClass
"333".to_date # => NoMethodError: undefined method `div' for nil:NilClass
# ActiveSupport 4
"asdf".to_date # => ArgumentError: invalid date
"333".to_date # => Fri, 29 Nov 2013
">Copy
ActiveSupport::TestCa
se#pending
method, use skip
from minitest instead.
ActiveSupport::Benchmarkable#si
lence
has been deprecated due to its lack of thread safety. It will be removed without replacement in Rails 4.1.
ActiveSupport::JSON::Variable
is deprecated. Define your own #
as_json
and #encode_json
methods for custom JSON string literals.
Deprecates the compatibility method Module#local_constant_name
s
, use Module#local_constants
instead (which returns symbols).
ActiveSupport::BufferedLogger
is deprecated. Use ActiveSupport
::Logger
, or the logger from Ruby standard library.
Deprecate assert_present
and as
sert_blank
in favor of assert o
bject.blank?
and assert object.
present?
change
migrations, making the old up
& dow
n
methods no longer necessary.
●The methods drop_table
and re
move_column
are now reversible, as long as the necessary information is given.
The method remove_column
used to accept multiple column names; instead use remove_columns
(which is not revertible).
The method change_table
is also reversible, as long as its block doesn't call remove
, change
orcha
nge_default
●New method reversible
makes it possible to specify code to be run when migrating up or down.
See the Guide on Migration
●New method revert
will revert a whole migration or the given block.
If migrating down, the given migration / block is run normally.
See the Guide on Migration
Adds PostgreSQL array type support. Any datatype can be used to create an array column, with full migration and schema dumper support.
Add Relation#load
to explicitly load the record and return sel
f
.
Model.all
now returns an Active
Record::Relation
, rather than an array of records. Use Relatio
n#to_a
if you really want an array. In some specific cases, this may cause breakage when upgrading.
Added ActiveRecord::Migration.c
heck_pending!
that raises an error if migrations are pending.
Added custom coders support for ActiveRecord::Store
. Now you can set your custom coder like this:
store :settings, accessors: [ :color, :homepage ], coder: JSON
mysql
and mysql2
connections will set SQL_MODE=STRICT_ALL_TABL
ES
by default to avoid silent data loss. This can be disabled by specifying strict: false
in your database.yml
.
Remove IdentityMap.
Remove automatic execution of EXPLAIN queries. The option acti
ve_record.auto_explain_threshol
d_in_seconds
is no longer used and should be removed.
Adds ActiveRecord::NullRelation
and ActiveRecord::Relation#non
e
implementing the null object pattern for the Relation class.
Added create_join_table
migration helper to create HABTM join tables.
Allows PostgreSQL hstore records to be created.
find_by_...
and find_by_...!
are deprecated. Here's
how you can rewrite the code:
●find_all_by_...
can be rewritten using where(...)
.
●find_last_by_...
can be rewritten using where(...).last
.
●scoped_by_...
can be rewritten using where(...)
.
●find_or_initialize_by_...
can be rewritten using find_or_i
nitialize_by(...)
.
●find_or_create_by_...
can be rewritten using find_or_creat
e_by(...)
.
●find_or_create_by_...!
can be rewritten using find_or_crea
te_by!(...)
.