Git Product home page Git Product logo

Comments (5)

amatsuda avatar amatsuda commented on May 14, 2024

ご報告ありがとうございます。
が、どうもこちらでは再現できていない感じです。
ひとつ確認なんですが、そのエラーが起きている状態でお手元のアプリ内の app/views/kaminari の中身をいったん消してみてもダメということでしょうか?

from kaminari.

kichiro avatar kichiro commented on May 14, 2024

rails newからEntryのモデルをcrudするだけのアプリを作りなおしてみました。
gemはkaminariとhaml、sqlite3の3つのみ。

  1. rails g scaffold entry title:string content:text
  2. app/views/layouts/application.html.erbを app/views/layouts/application.html.hamlとしてつくりなおす。同様にscaffoldが作成したindex.html.erb等を全てhamlになおす。
    3.この状態で、entryの作成と表示は可能。kaminariを使用しない一覧表示も可能。
  3. kaminariを使うようにする。indexアクションで@entries = Entry.order("entries.created_at DESC").page(params[:page])、viewで = paginate @entries
  4. viewに次のようなエラーが出力される。

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
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| -%>

エラーの最初のところに
「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:」
と出ているので、この状態でのアプリを見てみたところ、
app/views/kaminariディレクトリは存在しません。

なので、松田さんがお書き下さった
「お手元のアプリ内の app/views/kaminari の中身をいったん消してみてもダメということでしょうか?」は出来ません。

おそらく、いきなりhamlを使ってアプリをつくると、使うべきhamlのpagination用のテンプレートは無いのでエンジンのものを見に行こうとするものの、エンジン側は上のエラーにあるようなerbのテンプレートを出力しているのでうまくいかない、ということでしょうか? hamlの中でerbって出力できたような感じもしましたが…。

ともあれ、この手順でこのエラーが出力されていても、
この段階で
rails generate kaminari:views default -e haml
でapp/views/kaminari以下を作ると、期待通りにpagination部分が出力されるようになります。

次に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のセットです。

from kaminari.

amatsuda avatar amatsuda commented on May 14, 2024

ご丁寧な報告を本当にありがとうございます。おかげで無事(?)再現できました。
たぶんぬるぽが起きないように修正できたと思うので、次のバージョンでは直っているものと思われます。
(本当はバグが再現しないことをご確認いただいた上でチケットをクローズしたいのですが、GitHub Issuesの性質上、修正commitをpushするとこのチケットは自動クローズされてしまいます。お手数ですが、不具合が再発するようであれば、再度ご報告いただけるとありがたいです。)

from kaminari.

amatsuda avatar amatsuda commented on May 14, 2024

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

from kaminari.

kichiro avatar kichiro commented on May 14, 2024

headを持ってきて確認しました。どうもありがとうございました。

from kaminari.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.