Skip to content

Instantly share code, notes, and snippets.

@m-nakamura145
Last active December 3, 2018 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m-nakamura145/6a5508e8bc555c33243078fc37589e63 to your computer and use it in GitHub Desktop.
Save m-nakamura145/6a5508e8bc555c33243078fc37589e63 to your computer and use it in GitHub Desktop.
# コマンドライン引数で指定した店舗IDをデモ利用可能店舗として追加する。
restaurant_id = ARGV[0].to_i
raise "invalid restaurant id: #{ARGV[0]}" if restaurant_id.zero?
raise "restaurant_id : #{ARGV[0]} not found." unless Restaurant.exists?(restaurant_id)
property = SystemProperty.find_by(key: 'demo_restaurants')
demo_restaurant_ids = JSON.parse(property.value)
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