Skip to content

Instantly share code, notes, and snippets.

@Ch0k
Ch0k / select_tag rails
Created September 15, 2022 12:40 — forked from sameera207/select_tag rails
Using selected option in rails select_tag
year array -> ['2012','2011','2010','2009']
selected year -> 2010
<%= select_tag 'year_range', options_for_select(['2012','2011','2010','2009'],'2010') %>
which will always selects '2010'
If you are selecting an object
@Ch0k
Ch0k / rubocop_pre_commit_hook
Created June 3, 2022 12:11 — forked from palkan/rubocop_pre_commit_hook
Rubocop pre-commit hook
#!/usr/bin/env ruby
ADDED_OR_MODIFIED = /^\s*(A|AM|M)/.freeze
changed_files = `git status --porcelain`.split(/\n/)
unstaged_files = `git ls-files -m`.split(/\n/)
changed_files = changed_files.select { |f| f =~ ADDED_OR_MODIFIED }
changed_files = changed_files.map { |f| f.split(" ")[1] }