-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
undefined method `safe_concat' for nil:NilClass when used with HAML #11
Comments
ご報告ありがとうございます。 |
rails newからEntryのモデルをcrudするだけのアプリを作りなおしてみました。
NoMethodError in Entries#index Showing /Users/foo/.rvm/gems/ruby-1.9.2-p136/gems/kaminari-0.9.13/app/views/kaminari/_paginator.html.erb where line #9 raised: undefined method `safe_concat' for nil:NilClass Extracted source (around line #9): 6: remote: data-remote 11: <%= current_page > 1 ? prev_link_tag : prev_span_tag %> 12: <% each_page do |page| -%> エラーの最初のところに なので、松田さんがお書き下さった おそらく、いきなりhamlを使ってアプリをつくると、使うべきhamlのpagination用のテンプレートは無いのでエンジンのものを見に行こうとするものの、エンジン側は上のエラーにあるようなerbのテンプレートを出力しているのでうまくいかない、ということでしょうか? hamlの中でerbって出力できたような感じもしましたが…。 ともあれ、この手順でこのエラーが出力されていても、 次にapp/views/kaminariを削除すると、再び同じエラーが出るようになります。 kaminariのlib/kaminari/tags.rbの46行目あたり、「3. the default one inside the engine」のケースでtemplate_filenameメソッドを使う場合に、hamlの場合に見つからないもしくはerb版が見つかってしまう感じでしょうか? rails 3.0.4, ruby 1.9.2-p136, kaminari 0.9.13, haml 3.0.25のセットです。 |
ご丁寧な報告を本当にありがとうございます。おかげで無事(?)再現できました。 |
closed by 4809198 always create the paginator's own output_buffer rather than reusing the template's one because the template's output_buffer is not yet instantiated in some cases |
headを持ってきて確認しました。どうもありがとうございました。 |
ページ全体をhamlで書いている場合に、= paginate @entries でpaginationを出力しようとした場合に、「undefined method `safe_concat' for nil:NilClass」というエラーになりました。
(0.9.9までは大丈夫だった書き方)
rails generate kaminari:views default -e haml を実行しapp/views/kaminari以下にファイルを作ると、hamlの場合でもpaginationが出力できるようになり、特に問題はありません。
0.9.12で「Moved the whole pagination logic to the paginator partial」とあるので、そのためかもしれません。
ドキュメントのどこかに「hamlを使う場合は最初に rails generate kaminari:views default -e haml を実行しましょう」のようなことが書かれているほうが分かりやすいかもしれません。
以下、試した際にviewに出たエラーです。
バニラな環境で再現できます。
undefined method `safe_concat' for nil:NilClass
Extracted source (around line #9):
6: remote: data-remote
7: paginator: the paginator that renders the pagination tags inside
8: -%>
9: <%= paginator.render do -%>
10:
11: <%= current_page > 1 ? prev_link_tag : prev_span_tag %>
12: <% each_page do |page| -%>
The text was updated successfully, but these errors were encountered: