Skip to content

Instantly share code, notes, and snippets.

View secretpray's full-sized avatar
🎯
Focusing

Aleksander secretpray

🎯
Focusing
View GitHub Profile
Add ->
GemFile:
gem 'devise', '~> 4.8'
gem 'omniauth'
gem 'omniauth-facebook'
gem 'omniauth-github'
gem 'omniauth-google-oauth2'
gem 'activerecord-session_store'
gem 'omniauth-rails_csrf_protection'
Models:
-------
1)
user.rb
has_many :recipes
2)
recipe.rb # add counter_cache: true to recalculate posts_count field in user table
belongs_to :user, counter_cache: true
1)
# Gemfile
gem 'rails-i18n'
bundle
2)
bin/rails g migration add_language_to_users language
1. Gemfiles:
--------
gem 'rails-social-share-button'
2. Terminal
-----------
bundle
bin/rails generate social_share_button:install
3. Edit 'config/initializers/social_share_button.rb'
@secretpray
secretpray / PDF
Last active October 28, 2024 09:31
Export html page to PDF (Rails 6, Heroku)
----- Model: Recipe -----
1)
Gemfile
==========
gem 'grover' (https://github.com/Studiosity/grover)
Terminal
--------- model Recipe -------------
1) Controllers: Recipes
=======================
class RecipesController < ApplicationController
after_action :register_visit, only: :show
attr_accessor :recipe
helper_method :recently_recipes
0. Gemfile: (опционально/optional)
===========
gem 'hamlit-rails'
gem 'erb2haml'
gem 'simple_form'
1. Terminal
===========
yarn add choices.js
@secretpray
secretpray / Omniauth (service method)
Last active June 13, 2021 08:55
Omniauth (Facebook, Github, Google) with confirmation real email with Devise
=================
1. Add to Gemfile
=================
gem 'omniauth'
gem 'omniauth-facebook'
gem 'omniauth-github'
gem 'omniauth-google-oauth2'
gem 'activerecord-session_store'
gem 'omniauth-rails_csrf_protection'
@secretpray
secretpray / Infinity scroll
Last active October 20, 2021 19:04
Infinite scrolling with pagination (pagy)
-------------------- model Recipe + Favorites -----------------------
1. Add pagination:
===============
Gemfile
-------
gem 'pagy'
$bundle