1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CodePenとアンケートサービスを使ってQiitaの機能を拡張する - アンケートの埋め込み

1
Last updated at Posted at 2018-03-13

百見は一ポチにしかずなのでまずはアンケートを読んでポチってみてください。

nilへの対処法について

下記の3パターンの対処法を見て、後述のアンケートに回答をお願いいたします。

広告ブロックの拡張機能を入れていると下記の項目が表示されないようです。

  • google formのアンケート結果
  • survay monkeyの埋め込み

A ネストスタイル

def find_friend_message(name)
  unless self.user.nil?
    unless self.user.friends.nil?
      friend = self.user.friends.find_by(name: name)
      unless friend.nil?
        unless friend.message.blank?
          return friend.message
        end
      end
    end
  end
  'no message'
end

B ガードスタイル

def find_friend_message(name)
  no_msg = 'no message'

  return no_msg if self.user.nil?

  friend = self.user.friends.find_by(name: name)
  return no_msg if friend.nil?

  friend.message.blank? ? no_msg : friend.message
end

C セーフスタイル

def find_friend_message(name)
  self.user&.friends&.find_by(name: name)&.message || `no message`
end

アンケート Google Form

See the Pen Google Form by k.shimoji (@k-shimoji) on CodePen.

余談 - Survay Monkeyも使ってみました

See the Pen Gxpaqp by k.shimoji (@k-shimoji) on CodePen.

補足

google formの使い方参考:HipSoftHub - Google formsでアンケートフォームを作ってサイトに埋め込む方法

survay monkey使い方:Survay Monley - ヘルプセンター

まとめ

アンケート機能あった方が良いっしょ!codepenマジ便利です。

google formは画像も埋め込めてその点良かったです。

survay monkeyは回答がすぐに見れないのが残念でした。その点を除けばこっちの方が使いたくなるような出来なんですけどね。

google formも同じ挙動でした。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?