Rails, Firefox, Anime, Mac
A slight change this week since Rails has moved to Git – all changesets are now referenced to Github.
This week’s report covers changes from 7 Apr 2008 to 13 Apr 2008 (the day the corresponding Rails Envy podcast was recorded).
A helpers method has been introduced to ActionController – you can now access your helpers like so:
ApplicationController.helpers.simple_format(text)
Credit goes to 19 year old Josh Peek, one of the more prolific Rails contributors (and most likely to join Pratik in Rails Core imo).
Related changeset: http://github.com/rails/rails/commit/917423d664038d6791738a73ad1446437dbb71df
A json_escape (aliased as j, similar to how html_escape is aliased as h) has been introduced by Rick Olson for escaping HTML entities in JSON strings. This is useful if you find yourself emitting JSON strings in HTML pages (e.g. for documenting a JSON API):
json_escape("is a > 0 & a < 10?")
# => is a \u003E 0 \u0026 a \u003C 10?
Of course, since json_escape is aliased as j, you can do this in your ERB templates:
<%=j @person.to_json %>
Related changeset: http://github.com/rails/rails/commit/0ff7a2d89fc95dcb0a32ed92aab7156b0778a7ea
Rails will now accept POSTed JSON content! For example, you can now send a POST to “/posts” of your Post resource like this:
POST /posts
{"post": {"title": "Breaking News"}}
And your create action will automatically parse the POSTed JSON into the request params so that this code below just works:
def create
@post = Post.create params[:post]
end
Credit goes to Rick Olson.
Related changeset: http://github.com/rails/rails/commit/4d594cffcfc93b37fad4e423ec8593299e50133c
A new schema_migrations table for storing which migrations have been run has been introduced, and this replaces the existing schema_info table (which simply keeps track of the last applied schema version). This change makes it possible to add migrations (for example, after you’ve merged from someone’s branch) – when you migrate your database via rake db:migrate, those never-applied “interleaved” migrations will be run. Similarly, when migrating down schema versions, never-applied “interleaved” will be skipped.
See http://dev.rubyonrails.org/ticket/11493 for more information.
This useful patch is the brainchild of Jordi Bunster (WWR profile). I’m sure many Rails developers who branch extensively will thank Jordi for this excellent patch!
Related changeset: http://github.com/rails/rails/commit/8a5a9dcbf64843f064b6e8a0b9c6eea8f0b8536e
Remember how you can now run the gems:unpack Rake task to unpack a gem into your vendor/gems/ directory (this was mentioned in an earlier Living on the Edge)?
David Dollar (Github profile) has firmed up that patch quite a bit by adding the gems:unpack:dependencies Rake task that unpacks the dependencies of the gems as well. So running:
gems:unpack:dependencies GEM=activecouch
would unpack the full Rubygem dependency tree of gems that the activecouch gem depends upon.
Related changeset: http://github.com/rails/rails/commit/4364c361b599f99bc2345ce4eb2d145b07ed8a0f
As always, let me know of any suggestions or how I can improve the Living on the Edge (of Rails) series! Now go out there and start forking Rails!
1 Response to Living on the edge (of Rails) #16 – Github edition
A Fresh Cup » Blog Archive » Double Shot #186
April 14th, 2008 at 7pm
[...] Living on the Edge of Rails #16 (Github edition) – The latest from Edge Rails development. [...]