- Install git on your machine We recommend using RVM you can find directions for install and use here: http://beginrescueend.com/
- Fetch yogo sapphire project from the github repository at https://github.com/yogo/sapphire using $ git clone git@github.com:yogo/sapphire.git
- Then get into the sapphire directory created and if you are using rvm switch to ruby version 1.9.3 or greater and create an rvm gemset.
- execute a bundle install - this will install all the gems
- configure your database.yml file and create your database user accordingly (with CREATE DATABASE rights)
- run rake db:setup and rake db:automigrate - this will setup the database with the correct initial static tables
now you have a base Rails stack applicaton that uses the Yogo Framework that you can begin creating models and views for :)
user = User.new
user.email = "testing@test.com"
user.password = "password"
user.password_confrim = "password"
user.save
you should now be able to login with this user
project = Yogo::Project.create(:name=>”test”)
In lib/yogo the is a file stub called “project_ext.rb” and you can add properties to that to extend your base Project Model- there are comments and examples in this file to help.
This will allow a Yogo Project to become a new database and house all data related to it within it’s own repository. This also allows the repository to be protected by the authorizations related to the project(if the appropriate functions and memberships have been added previously) TODO - turn this block along with the associated models into a gem or something
has n, :memberships, :parent_key => [:id], :child_key => [:project_id], :model => 'Membership'
has n, :users, :through => :memberships
has n, :roles, :through => :memberships
after :create, :give_current_user_membership
def give_current_user_membership
unless User.current.nil?
Membership.create(:user => User.current, :project => self, :role => Role.first(:position => 1))
end
end
within the project model add:
require 'yogo/datamapper/repository_manager' include Yogo::DataMapper::RepositoryManager
coll = Yogo::Collection::Asset.new
project.data_collections << coll
c = project.data_collections.first
OR c = project.data_collections.create(:name=>"foobar")
foo = c.shema.new
foo.name = “Color”
foo.type = Yogo::Collection::Property::String
foo.save
new_property = project.data_collections.last.schema.create(:name => "Count", :type=>Yogo::Collection::Property::Integer)
The table is not created until a item is added. This is also how a new item is added.
my_item = c.items.new
my_item[“Color”] = “blue”
my_item.save
another_item = c.items.new
another_item["Count"] = 1
another_item.save