Skip to content

Commit

Permalink
Fix column passing to work correctly with Ruby 1.8.7.
Browse files Browse the repository at this point in the history
  • Loading branch information
mipearson committed May 24, 2012
1 parent 1c08e21 commit b768623
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/datagrid/renderer.rb
Expand Up @@ -12,7 +12,15 @@ def initialize(template)
end

def format_value(grid, column, asset)
value = column.html? ? @template.instance_exec(asset, grid, &column.block) : column.value(asset, grid)
value = if column.html?
if column.block.arity > 1
@template.instance_exec(asset, grid, &column.block)
else
@template.instance_exec(asset, &column.block)
end
else
column.value(asset, grid)
end
url = column.options[:url] && column.options[:url].call(asset)
if url
@template.link_to(value, url)
Expand All @@ -32,7 +40,7 @@ def table(grid, *args)
options[:html][:class] ||= "datagrid #{grid.class.to_s.underscore.demodulize}"
assets = args.any? ? args.shift : grid.assets
paginate = options[:paginate]
if paginate
if paginate
::Datagrid::Utils.warn_once(":paginate option is deprecated. Looks to https://github.com/bogdan/datagrid/wiki/Frontend.")
assets = assets.paginate(paginate)
end
Expand All @@ -57,7 +65,7 @@ def rows(grid, assets, options = {})
def order_for(grid, column)
@template.content_tag(:div, :class => "order") do
@template.link_to(
I18n.t("datagrid.table.order.asc", :default => "ASC"),
I18n.t("datagrid.table.order.asc", :default => "ASC"),
@template.url_for(grid.param_name => grid.attributes.merge(:order => column.name, :descending => false)),
:class => "order asc"
) + " " + @template.link_to(
Expand Down

0 comments on commit b768623

Please sign in to comment.