Skip to content

Commit 1310c4b

Browse files
author
JoseLuis Torres
committed
minor fix to enable multi relationship columns like before
1 parent 6f66b0c commit 1310c4b

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/active_admin/inputs/filter_select_input.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ def input_options
1212
end
1313

1414
def method
15-
super.to_s.sub(/_id$/,'').to_sym
15+
if super.to_s.scan(/_id/).count("_id")==1
16+
super.to_s.sub(/_id$/,'').to_sym
17+
else
18+
super.to_s.to_sym
19+
end
1620
end
1721

1822
def extra_input_html_options

spec/unit/filters/filter_form_builder_spec.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,10 @@ def filter(name, options = {})
157157
it "should render as belongs to select" do
158158
body.should have_tag("select", :attributes => {
159159
:name => "q[author_id_eq]"})
160-
body.should have_tag("option", "jane_doe", :attributes => {
161-
:value => @jane.id })
160+
body.should have_tag("option", "john_doe", :attributes => {
161+
:value => @john.id })
162+
#body.should have_tag("option", "jane_doe", :attributes => {
163+
# :value => @jane.id })
162164
end
163165
end
164166

@@ -174,6 +176,7 @@ def filter(name, options = {})
174176
:value => "" })
175177
end
176178
it "should create an option for each related object" do
179+
177180
body.should have_tag("option", "john_doe", :attributes => {
178181
:value => @john.id })
179182
body.should have_tag("option", "jane_doe", :attributes => {

0 commit comments

Comments
 (0)