This README would normally document whatever steps are necessary to get the application up and running.
-
Installation
Clone this repo to your local machine using https://github.com/SoftprodigyIndia/ror-apis.git or download the zip file from https://github.com/SoftprodigyIndia/ror-apis/archive/master.zip
-
Setup
- Run the following commands on your terminal to setup this project
-
Useful Links
Also swagger test module in "your_app_url/api" (eg:- http://localhost:3000/api)
- website link:- "https://rorapistaging.herokuapp.com/"
- Admin url :- "[email protected]"
- Admin url :- "admin@123"
-
some useful gems
CanCan is an authorization library for Ruby on Rails which restricts what resources a given user is allowed to access. All permissions are defined in a single location (the Ability class) and not duplicated across controllers, views, and database queries.
-Setup
- add gem "gem 'cancancan'" in gemfile and run bundle install.
- run by "rails g cancan:ability" to create User permissions are defined in an Ability class.
- Use "load_and_authorize_resource" method is provided to automatically authorize all actions in a RESTful style resource controller. It will use a before filter to load the resource into an instance variable and authorize it for every action.
- Handle Unauthorized Access: If the user authorization fails, a CanCan::AccessDenied exception will be raised. You can catch this and modify its behavior in the ApplicationController. class ApplicationController < ActionController::Base rescue_from CanCan::AccessDenied do |exception| redirect_to root_url, :alert => exception.message end end
- in our app abilities are define below:
abilities:
- Admin have an all access.
- Staff have an ability to update.
- Customer can manage their profile.
Active Admin is a Ruby on Rails framework for creating elegant backends for website administration.
-Setup
- add gem "gem 'activeadmin'" in gemfile.
- After updating your bundle, run the installer "rails generate active_admin:install"(The installer creates an initializer used for configuring defaults used by Active Admin as well as a new folder at app/admin to put all your admin configurations.) Note: Uncomment this line "require 'sprockets/railtie'" in application.rb/config.
- Migrate your db and start the server:
$> rails db:seed $ > rails db:migrate $> rails server - Visit http://localhost:3000/admin and log in using:
login: [email protected]
password: password
You’re on your brand new Active Admin dashboard.
- To register your first model, run: $> rails generate active_admin:resource ModelName(User)
active admin module in "your_app_url/api" (eg:- http://localhost:3000/admin)
- website link:- "https://rorapistaging.herokuapp.com/admin"
- Admin login :- "[email protected]"
- Admin password :- "password"