Skip to content

Instantly share code, notes, and snippets.

View wichru's full-sized avatar

Maciej Wicher wichru

  • Cracow
View GitHub Profile
<%= form_with url: kyc_document_upload_path, multipart: true do |f| %>
<% kyc_missing.each do |item| %>
<tr>
<td><%= item %></td>
<td>
<%= f.fields_for :files, index: nil do |ff| %>
<%= ff.hidden_field :document_name, value: item %>
<%= ff.file_field :file %>
<% end %>
</td>
# views/payments/index.html.erb
<%= turbo_frame_tag 'payments' do %>
<%== pagy_items_selector_js(@pagy)%>
<% end %>
class BetterAdvisor
def clothes
if weather_service.precipitation > 40
:raincoat
elsif weather_service.temperature > 20
:t_shirt
else
:jacket
end
end
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
* vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
$.ajax({
method: "GET",
url: "/tasks/search",
data: { query: query }
})
.done(function( suggestions ) {
var $suggestions = $('#suggestions')
var $suggestions_table = $suggestions.find('table tbody')
$suggestions_table.empty()
@wichru
wichru / no_post.rb
Created May 27, 2019 02:03
null object
class NoPost
def title
"No posts yet"
end
end
@wichru
wichru / new.html.erb
Created May 27, 2019 01:24
simple_form
<h2 align="center">Sign up</h2>
<div class="container">
<div class="col-sm-4">
<b>Personal data</b><hr>
</div>
<% if @registration.errors.any? %>
<h1>ERRORS</h1>
<% @registration.errors.full_messages.each do |message| %>
<ul><% message %></ul>
<% end %>
class StockRemoveWorker
include Sidekiq::Worker
sidekiq_options retry: false
def perform
Stock.destroy_all
end
end
@wichru
wichru / _form.rb
Created May 26, 2019 02:23
ActiveStorage
<%= form_for @article do |f| %>
<div class='form-group'>
<%= f.label :title %>
<%= f.text_field :title, class: 'form-control' %>
</div>
<div class='form-group'>
<%= f.label :image %>
<%= f.file_field :image, class: 'form-control' %>
</div>
<div class='form-group'>
# frozen_string_literal: true
class User::RegistrationsController < Devise::RegistrationsController
before_action :configure_permitted_parameters
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: %i[first_name last_name])
devise_parameter_sanitizer.permit(:account_update, keys: %i[first_name last_name])