# JsonVoorhees 1.0.0 ## Introduction I frequently take on projects that involve some kind of an api and it was a nightmare repeating all of the boilerplate code to get the backend in a useable state. I abstracted away all of the code that I typically use into a series of generators namespaced under json_voorhees. Not only does it set your project up, it also helps build the project if you follow the conventions. ## Scaffold Use To install, put this in your main_app and run bundle install. ```bash gem "json_voorhees" ``` To setup your application use the command below. It takes options that allow you to do things like skip active_admin, skip a generic admin page, skip arcadex, and even skip a user class. The default runs with active_admin, a user class and arcadex. ```bash rails g json_voorhees:setup_app ``` Now when you want to create an engine run the below command from the main app. It takes care of mounting the engine, setting up the controllers, routes and gemspecs. ```bash rails g json_voorhees:create_engine [engine name] ``` Now we can create resources, run the below command from the main_app. Specs will be created and the routes for that resource are setup. ```bash rails g json_voorhees:massive_scaffold [engine name] [resource name] [api_version] [scaffold parameters] example rails g json_voorhees:massive_scaffold chat message 1 user_id:integer message:text ``` ## Project Flow 1. Create main app 2. (in main_app root) rails g json_voorhees:setup_app 3. (in main_app root) rails g json_voorhees:create_engine [engine name] 4. (in main_app root) rails g json_voorhees:massive_scaffold [engine name] [resource name] [api_version] [field:type field:type] 5. (in main_app root) Copy migrations to main app and run db migrations in main app like so. "rake railties:install:migrations && rake db:migrate RAILS_ENV=development" 6. (in main_app root) Run "rspec" to check for errors I usually set the app up, and then design the database. I make a list of all the models I need, then separate them into engines. Then I run 20 or so massive scaffolds using "&&". The result is a modular functioning backend that only needs the model relationships wired together. The default tests get you pretty far. ## Individual Generator Use If massive scaffold is too bulky for you, you have the option of running the generators individually. Use rails g to see the generators that come with the gem and the options. They each have a multitude of arguments and options. 1. rails g json_voorhees:app_make_admin 2. rails g json_voorhees:app_make_authorizations 3. rails g json_voorhees:app_make_tests 4. rails g json_voorhees:app_make_user 5. rails g json_voorhees:app_scaffold 6. rails g json_voorhees:engine_create_controller 7. rails g json_voorhees:engine_create_model 8. rails g json_voorhees:engine_create_serializer 9. rails g json_voorhees:engine_scaffold 10. rails g json_voorhees:massive_scaffold 11. rails g json_voorhees:setup_app 12. rails g json_voorhees:setup_engine 13. rails g json_voorhees:create_engine ## Versioning This generator is strongly tied in with versioning. As so every model, controller, serializer, test and factory created with this tool are versioned. The main app hosts the application controllers and test suite. Everything else resides in engines for good modularity. ## Recent Additions Create the create_engine generator and made hooking the engine up to the main_app painless. ## Reminder For more granular control over tokens and the admin user, clone the github repos into the engines folder and point your gem file to that. Edit what you want. To setup admin restrictions, use the attributes for the admin class and put before_filters before all of the CRUD actions. Make sure the current_user has the correct permissions. If active admin is used (it is by default) the admin section username is admin and password is password. Otherwise the password is password123. ## To Do 1. Maybe give an option to include pagination? 2. Option for websockets and paperclip? 3. Make the non defaults easier to user 4. Use Devise as the default user and admin user? This will make it easier for users to reset their password as this is already setup. 5. Git clone arcadex, type_validator and defcon to make it easier for users to customize? 6. Move the people engine into it's own gem? 7. Create a whenever task to destroy expired tokens. 8. Fix the breadcrumbs link in ActiveAdmin. 9. Add a mailgun and support for forgotten passwords