-
Notifications
You must be signed in to change notification settings - Fork 8
[WIP] 参加団体 連絡先一覧 出力機能 #255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
| <td>メールアドレス</td> | ||
| </tr> | ||
| </tbody> | ||
| <%= @groups.each do |group| %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<%= は値をhtmlに埋め込むので,rubyコードを走らせたいだけのときは <% を使いましょう.
|
これでできてると思います |
| </tr> | ||
| </tbody> | ||
| <% @groups.each do |group| %> | ||
| <% row_span = get_subrep_by_group(group.id).try(:length) %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_subrep_by_group(group.id) や get_user_detail_by_group(group.user_id) で取得したデータを変数に格納してはどうでしょうか.
何回か同じメソッドを呼んでいますが引数が同じなので,一回取得して後はそれを使いまわすのが良いと思います.データベースに問い合わせする回数が減るので.
| <td>代表者</td> | ||
| <td><%= get_user_detail_by_group(group.user_id).first.name_ja %></td> | ||
| <td><%= get_user_detail_by_group(group.user_id).first.tel %></td> | ||
| <td><%= User.where(id:group.user_id).first.email %></td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
アソシエーションを設定しているのでUserレコードはUserDetailレコードから引いてこれます.
user_detail = get_user_detail_by_group(group.user_id)
user = user_detail.user.email # これで参照できるThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そもそも group から取ってこれますね
group.user.email
関連 #92
自分のローカルで既存のものも含めpdf出力ができません.