Comments (5)
ご報告ありがとうございます。
が、どうもこちらでは再現できていない感じです。
ひとつ確認なんですが、そのエラーが起きている状態でお手元のアプリ内の app/views/kaminari の中身をいったん消してみてもダメということでしょうか?
from kaminari.
rails newからEntryのモデルをcrudするだけのアプリを作りなおしてみました。
gemはkaminariとhaml、sqlite3の3つのみ。
- rails g scaffold entry title:string content:text
- app/views/layouts/application.html.erbを app/views/layouts/application.html.hamlとしてつくりなおす。同様にscaffoldが作成したindex.html.erb等を全てhamlになおす。
3.この状態で、entryの作成と表示は可能。kaminariを使用しない一覧表示も可能。 - kaminariを使うようにする。indexアクションで@entries = Entry.order("entries.created_at DESC").page(params[:page])、viewで = paginate @entries
- 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.
ご丁寧な報告を本当にありがとうございます。おかげで無事(?)再現できました。
たぶんぬるぽが起きないように修正できたと思うので、次のバージョンでは直っているものと思われます。
(本当はバグが再現しないことをご確認いただいた上でチケットをクローズしたいのですが、GitHub Issuesの性質上、修正commitをpushするとこのチケットは自動クローズされてしまいます。お手数ですが、不具合が再発するようであれば、再度ご報告いただけるとありがたいです。)
from kaminari.
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.
headを持ってきて確認しました。どうもありがとうございました。
from kaminari.
Related Issues (20)
- rails g kaminari:views bulma does not work on Ruby 3 HOT 2
- enter custom page number HOT 3
- rails g kaminari:views doesn't generate anything HOT 12
- Hi HOT 1
- undefined local variable or method `paginator' for _page.html.erb:22 partial HOT 2
- Undefined method `without_count' HOT 2
- Update wiki link in GitHub "About" section HOT 1
- issue on method_missing due to separation of positional and keyword arguments in Ruby 3
- Is it possible to add 'data-turbo-action' to the paginate helper? HOT 4
- How to use "Creating Friendly URLs and Caching" in "member do" ?
- With the update from i18n to v1.11.0 `:zero` in not longer supported as key
- Problem Monkey Patching Rails 7.0
- render error for js.erb
- when large table query, use total_count and total_pages slow
- paginate view helper is failing with includes HOT 3
- Updating content_for blocks
- `link_to_first_page` / `link_to_last_page` ?
- inconsistent results in case of LEFT OUTER JOIN, GROUP BY and HAVING HOT 2
- Array doesn't get paginated when total count is passed in HOT 1
- Ambiguous column "id" when PG COUNT is used with certain joins HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kaminari.