Defect #2
closedListing 5 projects on Welcome page
0%
Description
Jean-Philippe,
I think there is an issue on the welcome.rhtml page when the code lists all the projects:
<div class="splitcontentright">
<div class="box">
<h3><%=l(:label_project_latest)%></h3>
<ul>
<% for project in Projects Projects >
<li>
<= link_to project.name, :controller => 'projects', :action => 'show', :id => project > (<=
format_time(project.created_on) >)<br />
<=h project.description >
</li>
< end %>
</ul>
</div>
</div>
Or, perhaps more importantly in the welcome_controller.rb:
def index
@news = News.latest
@projects = Project.latest
end
Reason: If a user clicks on a non-public project where he is not a member, they will receive a blank page (error).
Perhaps it will be better not to see private projects where the user is not a member?
As a potential solution, let's update the Project.latest method to return 5 projects where logged_in_user is a member
or the project is public?
What do you think?
Todd
Files
Updated by Todd McGrath almost 18 years ago
Jean-Philippe,
I'll attach two patch files that solved it
(project.rb-PATCH.txt and welcome_controller.rb-PATCH.txt).
What do you think? (I'm coming from Java and trying to
learn more Ruby/Rails. I'm not very confident in Ruby yet
and appreciate any feedback)
Todd
Updated by Jean-Philippe Lang almost 18 years ago
Happy new year Todd !
I've corrected this bug, with a slight different solution (your
code was good but i prefer not to add a join).
I've modified "Latest news" too so that they are displayed
according to user's membership.
Just a thing about your code: don't forget that logged_in_user
can be nil (if nobody's logged).
Best regards,
Jean-Philippe