Mongoid support #5

Closed
wants to merge 11 commits into
from

Projects

None yet

2 participants

@ElvinEfendi

Added new branch called mongoid which will allow developers to use crudify with Mongoid ODM. Als instead of will_paginate now it uses kaminari.

@parndt
Collaborator
parndt commented Nov 16, 2012

Why did you change the paginator as well?

@ElvinEfendi

Because will_paginate does not support mongoid, but kaminari does. It also supports MongoMapper(someone might need in the future). As to will_paginate mongoid support, someone has already asked pull request but they have not merged it yet, you can check discussion here: mislav/will_paginate#193

@parndt parndt commented on the diff Dec 6, 2012
lib/crudify.rb
@@ -1,9 +1,3 @@
-require 'active_support'
-require 'active_record'
-require 'action_controller'
-require 'will_paginate'
-require 'meta_search'
@parndt
parndt Dec 6, 2012 Collaborator

Why did you unrequire all of these?

@ElvinEfendi
ElvinEfendi Dec 6, 2012

I did not implement searching so no need for meta_search, neither used will_paginate(instead used kaminari). Sorry for the rest seems I did mistake.

@parndt parndt commented on the diff Dec 6, 2012
lib/crudify/class_methods.rb
@@ -41,6 +41,7 @@ def set_what
end
def index
+ find_all_#{plural_name}
@parndt
parndt Dec 6, 2012 Collaborator

indentation wrong

@parndt parndt commented on the diff Dec 6, 2012
lib/crudify/class_methods.rb
@@ -131,22 +125,14 @@ def paginate_all_#{plural_name}
# If we have already found a set then we don't need to again
find_all_#{plural_name} if @#{plural_name}.nil?
- paginate_options = {:page => params[:page]}
+ scope = @#{plural_name}.page(params[:page])
@parndt
parndt Dec 6, 2012 Collaborator

indentation wrong

@parndt parndt commented on the diff Dec 6, 2012
lib/crudify/class_methods.rb
@@ -113,8 +108,7 @@ def scope_with_options(scope)
# Finds one single result based on the id params.
def find_#{singular_name}
- set_instance(#{class_name}.find(params[:id],
- :include => #{options[:include].map(&:to_sym).inspect}))
+ set_instance(#{class_name}.includes(#{options[:include]}).find(params[:id]))
@parndt
parndt Dec 6, 2012 Collaborator

👍

@parndt parndt commented on the diff Dec 6, 2012
lib/crudify/class_methods.rb
@@ -52,12 +53,6 @@ def new
def create
- # if the position field exists, set this object as last object, given the conditions of this class.
- if #{class_name}.column_names.include?("position")
- params[:#{singular_name}].merge!({
- :position => ((#{class_name}.maximum(:position, :conditions => #{options[:conditions].inspect})||-1) + 1)
- })
- end
@parndt
parndt Dec 6, 2012 Collaborator

Why did you remove this block of code?

@parndt parndt commented on the diff Dec 6, 2012
lib/crudify/class_methods.rb
- # Seems will_paginate doesn't always use the implicit method.
- if #{class_name}.methods.map(&:to_sym).include?(:per_page)
- paginate_options.update(:per_page => #{class_name}.per_page)
+ # if per page is default then set it
@parndt
parndt Dec 6, 2012 Collaborator

indentation wrong

@parndt parndt commented on the diff Dec 6, 2012
lib/crudify/class_methods.rb
)
- # Methods that are only included when this controller is searchable.
@parndt
parndt Dec 6, 2012 Collaborator

why the mass kill on searching?

@ElvinEfendi
ElvinEfendi Dec 6, 2012

I did not have time to port searching for mongoid

@parndt
Collaborator
parndt commented Dec 6, 2012

This seems to reduce functionality for the existing ORMs.

@parndt parndt closed this Jun 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment