Skip to content

Commit

Permalink
Reverted DataMapper's explicit String to Integer castings. Fixes padr…
Browse files Browse the repository at this point in the history
  • Loading branch information
Dario Cravero committed Jul 2, 2013
1 parent 0c1317b commit d532d35
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
11 changes: 1 addition & 10 deletions padrino-admin/lib/padrino-admin/generators/orm.rb
Expand Up @@ -100,8 +100,7 @@ def all
def find(params=nil)
case orm
when :activerecord, :minirecord, :mongomapper, :mongoid then "#{klass_name}.find(#{params})"
when :datamapper then "#{klass_name}.get(#{params}.to_i)"
when :couchrest then "#{klass_name}.get(#{params})"
when :datamapper, :couchrest then "#{klass_name}.get(#{params})"
when :sequel, :ohm then "#{klass_name}[#{params}]"
else raise OrmError, "Adapter #{orm} is not yet supported!"
end
Expand Down Expand Up @@ -149,14 +148,6 @@ def find_by_ids(params=nil)
end
end

def parse_many_ids_on_params
base = "params[:#{@name_singular}_ids].split(',').map(&:strip)"
case orm
when :activerecord, :minirecord, :datamapper, :sequel then "#{base}.map(&:to_i)"
else base
end
end

def multiple_destroy(params=nil)
case orm
when :ohm then "#{params}.each(&:delete)"
Expand Down
Expand Up @@ -76,7 +76,7 @@
flash[:error] = pat(:destroy_many_error, :model => '<%= @orm.name_singular %>')
redirect(url(:<%= @orm.name_plural %>, :index))
end
ids = <%= @orm.parse_many_ids_on_params %>
ids = params[:<%= @orm.name_singular %>_ids].split(',').map(&:strip)
<%= @orm.name_plural %> = <%= @orm.find_by_ids("ids") %>
<% if @orm.name_singular == @admin_model %>
if <%= @orm.name_plural %>.include? current_account
Expand Down

0 comments on commit d532d35

Please sign in to comment.