Last active
December 3, 2018 02:40
-
-
Save m-nakamura145/241dd4b93cf89cc1a2c397efe0aaee00 to your computer and use it in GitHub Desktop.
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
# == Schema Information | |
# | |
# Table name: system_properties | |
# | |
# id :integer not null, primary key | |
# key :string(255) not null | |
# value :text(65535) not null | |
# description :text(65535) | |
# created_at :datetime | |
# updated_at :datetime | |
# | |
# Indexes | |
# | |
# index_system_properties_on_key (key) UNIQUE | |
# | |
# コマンドライン引数で指定した店舗IDをデモ利用可能店舗として追加する。 | |
property = SystemProperty.find_by(key: 'demo_restaurants') | |
demo_restaurant_ids = JSON.parse(property.value) | |
unless Restaurant.exists?(ARGV[0]) | |
puts "restaurant_id :#{ARGV[0]} not found." | |
exit | |
end | |
restaurant_id = ARGV[0].to_i | |
if demo_restaurant_ids.include?(restaurant_id) | |
puts "restaurant_id :#{restaurant_id} have already been pushed." | |
exit | |
end | |
demo_restaurant_ids.push(restaurant_id) | |
property.update!(value: demo_restaurant_ids.to_json) | |
puts "push restaurant_id :#{restaurant_id}." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment