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

Upgrading to version 4 resulted in list of authors to no longer be available from the Posts form #491

Open
dianaq12 opened this issue Aug 29, 2018 · 0 comments

Comments

@dianaq12
Copy link

dianaq12 commented Aug 29, 2018

The user class we are using does NOT have a username database column associated with it. A change made in the PostsController is the addition of the "find_all_authors" method which will only load authors if that database column exists. I don't think we should require developers to alter their database table used for authors simply to add this column to it. Especially if a similar column already exists with a different name. I think a better solution is checking to see if an attribute exists with that name. This way the developer just needs to add an attribute called username to their class which can then return the actual username stored in whatever column it currently is in. To make this work for me I created a PostsController decorator with the following find_all_authors method:

def find_all_authors
    @authors = Refinery::Blog.user_class.all if (!Refinery::Blog.user_class.nil? && Refinery::Blog.user_class.new.attributes.keys.include?('username'))
end

Then in my user class I simply do:

attribute :username
def username
    self.name
end

Not sure if you agree with this approach.... If you do I'm happy to do a PR for this change.

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

No branches or pull requests

1 participant