Skip to content

Instantly share code, notes, and snippets.

View SeyZ's full-sized avatar

Sandro Munda SeyZ

View GitHub Profile
@SeyZ
SeyZ / 1 config-routes.rb
Created March 27, 2018 09:39
doc-rails-smart-collection-delete
# /config/routes.rb
Rails.application.routes.draw do
# MUST be declared before the mount ForestLiana::Engine.
namespace :forest do
# ...
delete '/LegalDoc/:id' => 'legal_docs#destroy'
end
mount ForestLiana::Engine => '/forest'
end
@SeyZ
SeyZ / 1 config-routes.rb
Created March 27, 2018 09:28
doc-rails-smart-collection-update
# /config/routes.rb
Rails.application.routes.draw do
# MUST be declared before the mount ForestLiana::Engine.
namespace :forest do
# ...
put '/LegalDoc/:id' => 'legal_docs#update'
end
mount ForestLiana::Engine => '/forest'
end
@SeyZ
SeyZ / 1 config-routes.rb
Created March 27, 2018 09:20
doc-rails-smart-collection-get
# /config/routes.rb
Rails.application.routes.draw do
# MUST be declared before the mount ForestLiana::Engine.
namespace :forest do
# ...
get '/LegalDoc/:id' => 'legal_docs#show'
end
mount ForestLiana::Engine => '/forest'
end
@SeyZ
SeyZ / 1 config-routes.rb
Created March 27, 2018 09:11
doc-rails-smart-collection-list
# /config/routes.rb
Rails.application.routes.draw do
# MUST be declared before the mount ForestLiana::Engine.
namespace :forest do
get '/LegalDoc' => 'legal_docs#index'
end
mount ForestLiana::Engine => '/forest'
end
@SeyZ
SeyZ / lib-forest_liana-collections-legal_doc.rb
Created March 27, 2018 09:01
doc-rails-smart-collection-simple
@SeyZ
SeyZ / lib-forest_liana-controllers-companies_controller.rb
Last active March 27, 2018 08:28
doc-rails-extending-the-admin-api
# /lib/forest_liana/controllers/companies_controller.rb
if ForestLiana::UserSpace.const_defined?('CompanyController')
ForestLiana::UserSpace::CompanyController.class_eval do
# We register the default behavior method to default_destroy before the override.
alias_method :default_destroy, :destroy
def destroy
teams = forest_user.dig('data', 'data', 'teams')
if teams.include?('Management')
@SeyZ
SeyZ / 1 Gemfile
Last active March 28, 2018 08:36
doc-rails-configure-cors
# Gemfile
source 'https://rubygems.org'
# ...
gem 'forest_liana'
gem 'rack-cors'
@SeyZ
SeyZ / 1 lib-forest_liana-collections-company.rb
Created March 27, 2018 08:07
doc-rails-smart-action-whoami
# /lib/forest_liana/collections/company.rb
class Forest::Company
include ForestLiana::Collection
collection :Company
action 'Whoami', type: 'global', endpoint: '/forest/whoami', http_method: 'GET'
end
@SeyZ
SeyZ / install
Created March 27, 2018 07:51
doc-rails-installation
# Add the liana to your application's Gemfile
gem 'forest_liana'
# Bundle it
bundle install
# Install it with the provided environment secret
rails g forest_liana:install YOUR-SUPER-SECRET-SECRET-KEY
@SeyZ
SeyZ / 1 lib-forest_liana-collections-customer.rb
Last active May 10, 2018 17:19
doc-rails-smart-action-download-file
# /lib/forest_liana/collections/customer.rb
class Forest::Customer
include ForestLiana::Collection
collection :Customer
action 'Generate invoice', download: true
end