Permalink
Browse files

added kaminari setup generator

  • Loading branch information...
1 parent 5e8abdc commit 41f56edaa37b7a547b6920c76378f181fb0f368a @kristianmandrup committed Nov 22, 2012
View
@@ -114,6 +114,11 @@ In your Kaminari initializer file, add this:
After that, Kaminari calls from Cell will render app/cells/../views/kaminari/* files, so you don’t need to add the entire app/views folder to Cells view paths
+To automate this, a generator is can be used:
+
+ $ rails g apotomo:kaminary_setup
+ append config/initializers/kaminari_config.rb
+
== Builders
class LoginCell < Cell::Rails
@@ -1,6 +1,6 @@
module Apotomo
module Generators
- class WidgetGenerator < ::Rails::Generators::NamedBase
+ class EngineSetupGenerator < ::Rails::Generators::NamedBase
source_root File.expand_path("../templates", __FILE__)
def create_initializer
@@ -0,0 +1,27 @@
+module Apotomo
+ module Generators
+ class KaminariSetupGenerator < ::Rails::Generators::Base
+ # source_root File.expand_path("../templates", __FILE__)
+
+ def create_initializer
+ append_to_file kaminari_config_file do
+ kaminari_config_code
+ end
+ end
+
+ protected
+
+ def kaminari_config_file
+ "config/initializers/kaminari_config.rb"
+ end
+
+ def kaminari_config_code
+ %q{
+Kaminari::Helpers::Tag.class_eval do
+ def to_s(locals = {}) #:nodoc:
+ @template.render :partial => "../views/kaminari/#{@theme}#{self.class.name.demodulize.underscore}", :locals => @options.merge(locals)
+ end
+end
+}
+ end
+end

1 comment on commit 41f56ed

kuraga commented on 41f56ed Feb 25, 2013

Would we create code (that doesn't fix issues) for very special gems, Nick?

Please sign in to comment.