Skip to content

Instantly share code, notes, and snippets.

View davidtolsma's full-sized avatar

David Tolsma davidtolsma

View GitHub Profile
@davidtolsma
davidtolsma / rails-docker
Last active November 5, 2023 12:29
This sets up docker for rails with nginx, postgres, redis, sidekiq, and action_cable, # rails 6.1 # ruby 2.7.2 # required gems: pg, redis, sidekiq # requires config/sidekiq.yml config/initializers/sidekiq.rb cable/config.ru
# rails app:template LOCATION='https://gist.github.com/davidtolsma/3af8f8961abe3a635e41776fe2f3af54/raw'
# This sets up docker for rails with nginx, postgres, redis, sidekiq, and action_cable
# rails 6.1
# ruby 2.7.2
# required gems: pg, redis, sidekiq
# requires config/sidekiq.yml config/initializers/sidekiq.rb cable/config.ru
create_file 'docker/nginx/Dockerfile' do <<~YAML
# rails app:template LOCATION='https://gist.github.com/davidtolsma/b59c85845a76b47d0cb94dc88f340d28'
def ask_with_default(prompt, default)
value = ask("#{prompt} (default: #{default})")
value.present? ? value : default
end
run "bundle add 'friendly_id'"
rails_command "generate friendly_id"
@brunopgalvao
brunopgalvao / _form.html.erb
Last active December 23, 2022 02:32
HTML5 Datalist using Ruby on Rails form_for
<%= form_for @person do |f| %>
<%= f.label :first_name, "First Name" %>:
<%= f.text_field :first_name, list: 'first-name' %>
<datalist id="first-name">
<% Person.all.each do |person| %>
<option value="<%= person.first_name %>"></option>
<% end %>
</datalist>
<%= f.submit %>
<% end %>
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end