Skip to content

Conversation

@kichikawa
Copy link
Contributor

@kichikawa kichikawa commented May 4, 2018

関連 #92

自分のローカルで既存のものも含めpdf出力ができません.

image

@kichikawa
Copy link
Contributor Author

表の上に出てきちゃうんですけどこれどこが悪いんですかね?

test

<td>メールアドレス</td>
</tr>
</tbody>
<%= @groups.each do |group| %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<%= は値をhtmlに埋め込むので,rubyコードを走らせたいだけのときは <% を使いましょう.

@kichikawa
Copy link
Contributor Author

これでできてると思います
確認お願いします

</tr>
</tbody>
<% @groups.each do |group| %>
<% row_span = get_subrep_by_group(group.id).try(:length) %>
Copy link
Contributor

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>
Copy link
Contributor

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 # これで参照できる

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

そもそも group から取ってこれますね

group.user.email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants