This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= turbo_stream.update "panel" do %> | |
<% if params[:position].to_i <= 5 %> | |
<p>Less or equal to 5</p> | |
<% else %> | |
<p>more than 5</p> | |
<% end %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# build a form that posts a document (or whatever) and the form must have the starts_at and ends_at attributes | |
# you might need to adjust the attributes | |
@documents = Document.all | |
# if we have the params | |
@documents = @document.where(referenced_at: params[:document][:starts_at]..params[:document][:ends_at]) if ..... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cligest::DocumentsController < ApplicationController | |
# ... | |
def index | |
@document_search = DocumentSearch.new(document_search_params) | |
@documents = @document_search.perform | |
# perhaps a few more initializations | |
respond_to do |format| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Some rubocop offenses are an insult to programmers | |
AllCops: | |
TargetRubyVersion: 2.5 | |
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop | |
# to ignore them, so only the ones explicitly set in this file are enabled. | |
DisabledByDefault: true | |
Exclude: | |
- 'db/**/*' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const app = express() | |
app.set('view engine', 'pug'); | |
app.set('views','./views'); | |
app.get('/', function (req, res) { | |
var users = []; | |
var mysql = require('mysql') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Users</h1> | |
<%= search_form_for @q, url: dashboard_index_path do |f| %> | |
<%= f.label :name_cont %> | |
<%= f.search_field :name_cont %> | |
<%= f.submit %> | |
<% end %> | |
<ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scope :category_query, ->(query) do | |
if query.count == 1 | |
joins(:article_categories).where('article_categories.category_id': query.first) | |
else | |
joins(:article_categories). | |
where('article_categories.article_id': ArticleCategory.select('article_categories.article_id') | |
.where(category_id: query) | |
.group('article_categories.article_id') | |
.having("COUNT(article_categories.article_id) > #{query.count - 1}")) | |
.uniq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"ensure_newline_at_eof_on_save": true, | |
"font_size": 12, | |
"ignored_packages": | |
[ | |
"Vintage" | |
], | |
"save_on_focus_lost": true, | |
"tab_size": 2, | |
"translate_tabs_to_spaces": true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
gem 'carrierwave', github: 'carrierwaveuploader/carrierwave' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SessionsController < ApplicationController | |
def create | |
auth = request.env["omniauth.auth"] | |
session[:omniauth] = auth.except('extra') | |
user = User.sign_in_from_omniauth(auth) | |
session[:user_id] = user.id | |
redirect_to root_url, notice: "Signed In" | |
end |
NewerOlder