Skip to content

Commit

Permalink
Merge pull request #17 from CodiTramuntana/change_table_for_header_la…
Browse files Browse the repository at this point in the history
…bels

fix table headers for associated model with ransack
  • Loading branch information
Isaac Massot authored May 24, 2019
2 parents 8000526 + 3c3b233 commit 07388f3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Changelog

## version 0.1.14.beta to be released
## version 1.0.2 to be released

- ...

## version 1.0.1

- fix table headers for associated model with ransack

## version 0.1.13.beta

- added whole row clikable link as an option
Expand Down
6 changes: 5 additions & 1 deletion app/helpers/ct_table_for/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ def table_for_header model, has_actions: false, options: {}
html << %Q{<th>}
attribute, *params = attribute.split(":")
html << if defined?(Ransack) and params.include? "sortable"
sort_link(@q, attribute, I18n.t("#{attribute}", scope: [:activerecord, :attributes, model.to_s.underscore]).capitalize )
if params.length > 1 && !params.include?("l")
sort_link(@q, "#{attribute}_#{params.first}", I18n.t("#{attribute.to_s.underscore}_#{params.first}", scope: [:activerecord, :attributes, model.to_s.underscore]).capitalize )
else
sort_link(@q, attribute, I18n.t("#{attribute}", scope: [:activerecord, :attributes, model.to_s.underscore]).capitalize )
end
else
model.human_attribute_name("#{attribute}")
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ct_table_for/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module CtTableFor
VERSION = '1.0.0'
VERSION = '1.0.1'
end

0 comments on commit 07388f3

Please sign in to comment.