Browse files

bump version, better README, rake task will honor a VALIDATIONS_FILE …

…env variable
  • Loading branch information...
1 parent ad0263a commit b1edae008ec9d7a02ca5435507c9f0ea96aa6ce0 Chris Nelson committed Oct 12, 2012
Showing with 15 additions and 12 deletions.
  1. +12 −10
  2. +1 −1 lib/backtastic/version.rb
  3. +2 −1 lib/tasks/validations.rake
@@ -16,29 +16,31 @@ Usage
To get started, add it to your Gemfile:
gem "backtastic"
Then, somewhere in your manifest, require it:
#= require "backtastic"
Next, you'll create a view that is a subclass of Backtastic.Views.FormView
class EditPersonView extends Backtastic.Views.FormView
template: JST["edit_person_view_tempate"]
Backtastic provides a render method that will invoke your template with the view itself as the template context. This means methods from the FormView are available for use in your templates, and this is how the form field helpers work.
= @textField(label: "Name", field: "Name")
The field helper method (`@textField()` in this example) creates a subview of the appropriate type which renders a label and form input using twitter bootstrap friendly markup. They also listen to the model for validation errors and display appropriate styling and error messages.
-Rails validation on the server side will be handled appropriately by the form element views. You can also add client side validation. So far we support presence and format, checkout the Person backbone model in the example app to see how it works. We'll be adding support for reflecting on the rails model adding client side validations to the backbone model "real soon now".
+Backtastic supports both client side and server side validation. If you send back an error response with errors represented as jon, backtastic will decode the json and match up the error messages with fields.
+As of 0.4, backtastic gives you a way to reflect (some) validations from rails models onto your backbone models. There is a rake task, backtastic:validations:build, which generates a coffeescript file that puts validation data from rails onto a Backtastic.Rails.validations. Then some where in your client side code, you can require this file and call Backtastic.applyValidations. See the example app code to understand better how all this fits together.
Example App
@@ -47,7 +49,7 @@ The best way to learn how to use backtastic is to spend some time checking out t
bundle install
rake db:migrate
bundle exec rails s
Point your browser at localhost:3000. But then you probably knew that already
Running specs
@@ -56,21 +58,21 @@ Running specs
The specs for backtastic are in the example as well so I can take advantage of the asset pipeline in my specs. To run them, do:
rake jasminerice:run
Future plans
I'd like to have some metadata generated form rails and available to backbone so you could do something more formtasticy like:
@form fields["first_name", "last_name"]
Shameless self-promotion
If in-person training in all this is something that could help you or someone you know, we've [got you covered]( Should you need help building a backbone rails app, we can [do that too](
@@ -1,3 +1,3 @@
module Backtastic
- VERSION = "0.0.3"
+ VERSION = "0.4.0"
@@ -2,6 +2,7 @@ namespace :backtastic do
namespace :validations do
desc "Build put validation metadata in app/assets/javascripts"
task :build => :environment do
+ output = ENV["VALIDATIONS_FILE"] || Rails.root.join("app", "assets", "javascripts", "")
Dir[Rails.root.join "app", "models", '**', '*.rb'].each do |file|
require file
@@ -10,7 +11,7 @@ namespace :backtastic do
erb =, "..", "templates", ""))
-"app", "assets", "javascripts", ""), "w") { |f| f.puts(erb.result) }
+, "w") { |f| f.puts(erb.result) }

0 comments on commit b1edae0

Please sign in to comment.