All,
I've encountered a bug that others have (see
http://communityengine.lighthouseapp.com/projects/11808-communityengine/tickets/78)
involving the home page (BaseController#site_index action) throwing an
error if a user has not been activated. I've seen this bug explained
as simply making it necessary to activate your first user in the
system. I have confirmed that this occurs ANYTIME you have a user
join, because while the user is waiting to activate, as long as his
activity is in the last 5 activity entries, anytime a user hits the
site_index page it will bork.
The reason is that the invocation of User#find_by_activity by
BaseController#get_additional_homepage_data scopes the User model on
active users (base_controller.rb:128). But when the Activity lookup
happens (user.rb:157) no accounting is made for filtering out
activities referring to inactive users. In fact, you're practically
guaranteed that there will be an activity entry referring to an
inactive user: the activity entry of the inactive user logging in. So
when this is done at the end of the #find_by_activity method:
activities.map{|a| find(a.user_id) }
Of course it can't find the user, because it's looking for an inactive
user id in User.active! I fixed it by changing the above line to:
activities.map{|a| find_by_id(a.user_id) }.compact
This will throw out any unfound users instead of raising an
ActiveRecord:Record Not Found exception.
I've submitted a pull request to bborn's fork along with a unit test
that validates the problem:
def test_should_not_bork_find_in_activity_on_inactive_users
inactive_user = create_user
assert !inactive_user.active?
Activity.create(:user => inactive_user)
assert_nothing_raised do
User.active.find_by_activity({:limit => 5, :require_avatar =>
false})
end
end
You can check out my fork at:
http://github.com/jeremy6d/communityengine
- Jeremy
--
You received this message because you are subscribed to the Google Groups
"CommunityEngine" group.
To post to this group, send email to [email protected].
For more options, visit this group at
http://groups.google.com/group/communityengine?hl=.