You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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:
Then in my user class I simply do:
Not sure if you agree with this approach.... If you do I'm happy to do a PR for this change.
The text was updated successfully, but these errors were encountered: