README.md in basepack-0.0.2 vs README.md in basepack-0.1.0

- old
+ new

@@ -1,70 +1,76 @@ Basepack ======= +[![Gem Version](https://badge.fury.io/rb/basepack.png)](http://badge.fury.io/rb/basepack) [![Build Status](https://api.travis-ci.org/lksv/basepack.png?branch=master)](http://travis-ci.org/lksv/base_pack) [![Dependency Status](https://gemnasium.com/lksv/basepack.png)](https://gemnasium.com/lksv/basepack) **Basepack** is a Ruby on Rails framework for quick creation of information -systems. +systems. +**Basepack** dramatically helps you to start your new project. +There are out of the box form fields like: date (datepicker), datetime, html5 +wysiwig, tags, file upload and others. Further more there is support for +dynamic field hiding depending on state of other fields as well as +options of selectbox content modifications dependant on other fields. + +**Basepack** contains a lot of predefined forms, views and actions which you might need +(filter form, bulk changes, delete\_all, import, export, ...). + ## Features * Quick development of forms - generates forms for resource by short DSL metadata settings. * Rich set of business types support (datetime, wysiwig, tags, phone number, ...) * Search and filtering, saved filters * Automatic form validation * Import and Export functionality for resource * Easy way to create custom actions +* Security: permited parameters are automatically defined against fields in edit forms which are (read-write). * Authentication (via [Devise](ttps://github.com/plataformatec/devise)) * Authorization (via [Cancan](https://github.com/ryanb/cancan.git)) +All the field form definitions are done by [RailsAdmin](https://github.com/sferik/rails_admin) and are configured +accordingly. It simplifies configuration process and if you wish to use +RailsAdmin as an admin interface. + + ## Documentation -[Turorial](https://github.com/lksv/basepack/wiki/Tutorial) +[Tutorial](https://github.com/lksv/basepack/wiki/Tutorial) See project [wiki](https://github.com/lksv/basepack/wiki). ## Demo -*currently we are preparing +*Currently [zorec](https://github.com/zorec) is preparing [basepace_example application](https://github.com/zorec/basepack_example)* The running application will be available at [http://basepack-example.herokuapp.com/](http://basepack-example.herokuapp.com/) ## Installation In your `Gemfile`, add the following dependencies: - gem "basepack", git: "https://github.com/lksv/basepack.git" + gem "basepack" Run: bundle install And then run: rails g basepack:install -This generator will install **Basepack**, -[Devise](https://github.com/plataformatec/devise) and -[CanCan](https://github.com/ryanb/cancan.git) and following gems -* inherited\_resources -* ransack -* kaminari -* simple\_form -* settingslogic -* twitter-bootstrap-rails -* bootbox-rails +The generator will install several gems. Also, generator asks to delete +`app/views/layouts/application.html.erb` because differend .haml version will be created. +If you don't know what to answer then answer 'yes' to generator's question. -if you don't already have them installed. +In a bigger project do not forget to change ability in `app/models/ability.rb`. By +default, the generator adds ```can :manage, :all``` to enable anybody to perform any action on any object. +See more on [CanCan wiki](https://github.com/ryanb/cancan/wiki/Defining-Abilities). -Define inital ability in `app/models/ability.rb`. You can put ```can -:manage, :all``` to enable anybody to perform any -action on any object. See more on [CanCan -wiki](https://github.com/ryanb/cancan/wiki/Defining-Abilities). - Migrate your database and start the server: rake db:migrate rails s @@ -80,18 +86,24 @@ Then ```rake db:migrate``` ```rails s``` -Notice that files for views are not generated (directories appp/views/projects and appp/views/tasks are empty), but all RESTful actions are working correctly. It is because views iherit default structure and you can easily override these defaults by creating appropriate files. +Notice that: +1. Generated controllers inherits form ResourcesController. +2. Files for views are not generated (directories appp/views/projects +and appp/views/tasks are empty), but all RESTful actions are working correctly. +It is because views inherit default structure from controller inheritance) +and you can easily override these defaults by creating appropriate files. ## Basic usage After scaffolding your resources, you can customize fields used in individual actions by [Railsdmin DSL](https://github.com/sferik/rails_admin/wiki/Railsadmin-DSL) File ```app/models/project.rb```: -``` + +```ruby class Project < ActiveRecord::Base has_many :tasks, inverse_of: :project validates :name, :short_description, presence: true rails_admin do @@ -118,47 +130,54 @@ end end ``` File ```app/models/task.rb``` -``` +```ruby class Task < ActiveRecord::Base belongs_to :project, inverse_of: :tasks - belongs_to :user + belongs_to :user, inverse_of: :tasks end ``` -IMPORTANT! Make sure that you define inverse_of option on has_one, has_many and belongs_to associations. It is necessary for correct functioning of **Basepack**, see [Rails documentation](http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#label-Bi-directional+associations) for explaination. +Add folowing line to ```app/models/user``` file: +```ruby + has_many tasks, inverse_of: user +``` -Another difference is controllers which inherit from ResourcesController. Full inheritance hierarchy looks this way: +Pleas note that ```inverse_of``` option is included on association. It is +necessary for correct functioning of **Basepack**, see +[Rails documentation](http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#label-Bi-directional+associations) +and [RailsAdmin +wiki](https://github.com/sferik/rails_admin/wiki/Associations-basics#inverse_of-avoiding-edit-association-spaghetti-issues) +for explaination. + + +Almoust all the staff what Baseback do is through Basepack::BaseController which inherit from ResourcesController. Full inheritance hierarchy looks this way: ``` ProjectsController < ResourcesController < Basepack::BaseController < InheritedResources::Base ``` If you are not familiar with [InheritedResources](https://github.com/josevalim/inherited_resources), take a look at it. -Basepack::BaseController adds to it: -* strong parameters handling -* ```options``` method -* ```taggings``` method -* ```build_resource``` method - You do NOT need to define permitted parameters anymore. It is defined by RailsAdmin DSL, more precisely by what you set as visible in edit action. So file ```app/models/project.rb```: -``` +```ruby class Project < ActiveRecord::Base - ... + #... + rails_admin do + #... edit do field :name field :short_description field :description, :wysihtml5 field :start field :finish end - ... + end end ``` implicitly sets permitted params which could be written as: ``` @@ -189,27 +208,28 @@ [Device](https://github.com/plataformatec/devise). **Basepack** was also inspired by [RailsAdmin](https://github.com/sferik/rails_admin) and still using [RailsAdmin -DSL](https://github.com/sferik/rails_admin/wiki/Railsadmin-DSL) for defining the forms. +DSL](https://github.com/sferik/rails_admin/wiki/Railsadmin-DSL) for defining the forms, sessins and fields group. -TODO - explain the concept. Class ```Basepack::Form::Base``` and ```Basepack::Form::Fields::Base```. -Controller action as ```<form_name>_form_for``` and ```form_factory_rails_admin```. - -## Customining Views - -## Customizing Form View - License ======= This project rocks and uses LGPL-LICENSE. Credits ======= -[RailsAdmin](https://github.com/sferik/rails_admin) field forms was +[RailsAdmin](https://github.com/sferik/rails_admin) field views and some forms (export form) was originaly taken from rails-admin. [nested_form_ui](https://github.com/tb/nested_form_ui) - stylesheed and code for orderable was inspired by this project. + + + + + + + +[![Analytics](https://ga-beacon.appspot.com/UA-46491076-2/basepack/README.md?pixel)](https://github.com/igrigorik/ga-beacon)