Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

version bumpin' and adding a spike of rails metadata

  • Loading branch information...
commit afbbc2ba0001bf0dfbfd603ea260fd33ba162cbe 1 parent bc10840
Chris Nelson authored
View
3  example/app/assets/javascripts/backbone/rails_metadata.coffee.erb
@@ -1,6 +1,3 @@
<% ActiveRecord::Base.descendants.each do |model| %>
Example.Models["<%= model.to_s %>"].schema = <%= Backtastic.schema_for(model).to_json %>
- <% model.columns.each do |col| %>
- <%= col.name %>: "<%= col.type.to_s %>"
- <% end %>
<% end %>
View
2  example/app/models/person.rb
@@ -1,5 +1,5 @@
class Person < ActiveRecord::Base
- validates_presence_of :first_name
+ # validates_presence_of :first_name
belongs_to :occupation
end
View
2  example/spec/backtastic_spec.rb
@@ -2,5 +2,5 @@
describe "schema_for" do
Given(:person_schema) { Backtastic.schema_for(Person) }
- Then { person_schema["first_name"]["type"].should == "string" }
+ Then { person_schema["first_name"]["type"].should == :string }
end
View
6 lib/backtastic.rb
@@ -2,11 +2,17 @@
require 'rails-backbone'
require "inflection-js-rails"
require "twitter-bootstrap-rails"
+require "active_support/inflections"
module Backtastic
class BacktasticEngine < Rails::Engine
end
def self.schema_for(model)
+ schema = {}
+ model.to_s.constantize.columns.each do |col|
+ schema[col.name] = {"type" => col.type }
+ end
+ schema
end
end
View
2  lib/backtastic/version.rb
@@ -1,3 +1,3 @@
module Backtastic
- VERSION = "0.0.1"
+ VERSION = "0.0.2"
end

0 comments on commit afbbc2b

Please sign in to comment.
Something went wrong with that request. Please try again.