Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

truncate display_name_methods values #3886

Open
wants to merge 1 commit into
base: master
from

Conversation

@timoschilling
Copy link
Member

timoschilling commented Apr 9, 2015

There are some methods in that list which are to specific for some use cases. We should setup only display_name as ActiveAdmin default and to_s as fallback.

:title,
:email,
:to_s ]
setting :display_name_methods, [ :display_name, :to_s ]

This comment has been minimized.

@houndci-bot

houndci-bot Apr 9, 2015

Space inside square brackets detected.

@@ -27,7 +27,8 @@
allow(klass).to receive(:reflect_on_all_associations).and_return [ double(name: :login) ]
allow(subject).to receive :login
expect(subject).to_not receive :login
allow(subject).to receive(:email).and_return 'foo@bar.baz'
allow(ActiveAdmin.application).to receive(:display_name_methods).and_return [:login, :display_name]

This comment has been minimized.

@houndci-bot

houndci-bot Apr 9, 2015

Line is too long. [103/80]

@@ -27,7 +27,8 @@
allow(klass).to receive(:reflect_on_all_associations).and_return [ double(name: :login) ]
allow(subject).to receive :login
expect(subject).to_not receive :login
allow(subject).to receive(:email).and_return 'foo@bar.baz'
allow(ActiveAdmin.application).to receive(:display_name_methods).and_return [:login, :display_name]
allow(subject).to receive(:display_name).and_return 'foo@bar.baz'

This comment has been minimized.

@houndci-bot

houndci-bot Apr 9, 2015

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@timoschilling timoschilling force-pushed the truncate_display_name_methods branch from e1d64ce to 1b030c7 Apr 9, 2015
@timoschilling timoschilling force-pushed the truncate_display_name_methods branch from 1b030c7 to 92f6af4 Apr 9, 2015
@mattvague
Copy link
Contributor

mattvague commented Apr 9, 2015

@timoschilling Was this causing an issue for you somewhere? I was always kind of a fan of this feature as a smart default 😃

@dmitry
Copy link
Contributor

dmitry commented Apr 11, 2015

👍 becuase it's now more predictable. In other cases, you are always can add more names to the settings array.

@timoschilling
Copy link
Member Author

timoschilling commented Apr 11, 2015

The old one is sometimes confusing. I share @dmitry's opinion. The new List ist more explicit.

I think about to rename display_name to active_admin_display_name or something like that. To avoid conflicts and to decelerate for what the method is on the model.

I'm waiting with the merge for more discussion.

@mattvague
Copy link
Contributor

mattvague commented Apr 20, 2015

Alright, fair enough. What if instead of changing display_name to active_admin_display_name, we add a display_name_method DSL method to resources and fall back to calling display_name on models? Something like:

ActiveAdmin.register User do
  # ...
  display_name_method :name
  # ...
end

I think it's might be better to do this than mixing ActiveAdmin-related presentation logic into models. Thoughts?

@mattvague
Copy link
Contributor

mattvague commented Apr 20, 2015

(This is probably beyond the scope of this PR though, and something I would be happy to tackle)

@timoschilling
Copy link
Member Author

timoschilling commented Apr 21, 2015

@mattvague I like the idea of not mixing ActiveAdmin-related presentation logic into models! But what is with Models which are not registered in ActiveAdmin? How should they be configured?

@mattvague
Copy link
Contributor

mattvague commented Apr 22, 2015

@timoschilling That's a good question. Would it make sense to just rely on #display_name and any other methods registered in display_name_methods for these models?

If people want AA-specific display names for models that they don't want in the menu they would have 2 options:

  1. Register something like active_admin_display_name in display_name_methods themselves
  2. Register the resource, specify display_name_method, and hide the resource from the menu (menu false)
@mattvague
Copy link
Contributor

mattvague commented Apr 28, 2015

@timoschilling Thoughts?

@seanlinsley
Copy link
Member

seanlinsley commented May 4, 2015

I really don't think this is something that should change, when we haven't even gotten out 1.0.0. People have relied on this behavior for many years now, and there's no good way to warn them that it's changed. If we're going to change this, it should wait until 2.0.

@javierjulio
Copy link
Member

javierjulio commented Jul 26, 2017

@timoschilling we are moving forward with breaking changes for master (for a v2). Are you able to update the conflicts so we can review for merging in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants
You can’t perform that action at this time.