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
# 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 |
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
# 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" |
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
<%= 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 %> |
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
# config/routes.rb | |
resources :documents do | |
scope module: 'documents' do | |
resources :versions do | |
post :restore, on: :member | |
end | |
resource :lock | |
end | |
end |