Skip to content

Commit

Permalink
adding limit to the users/talks listing and adding pages to list all
Browse files Browse the repository at this point in the history
  • Loading branch information
tpinto committed Jul 4, 2008
1 parent 3b4f0be commit c08ecdd
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
6 changes: 4 additions & 2 deletions app/controllers/events_controller.rb
@@ -1,8 +1,10 @@
class EventsController < ApplicationController

def index
@users = @event.users
@talks = @event.talks
@users = User.find :all, :order => "id DESC", :limit => 10
@user_count = User.count
@talks = Talk.find :all, :order => "id DESC", :limit => 5
@talk_count = Talk.count
@posts = Post.find :all, :order => "id DESC"
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/talks_controller.rb
Expand Up @@ -22,7 +22,7 @@ def create
end

def index
@talks = @event.talks
@talks = Talk.find :all, :order => "id DESC"
end

def show
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/users_controller.rb
Expand Up @@ -9,6 +9,10 @@ def show
@user = User.find(params[:id])
end

def index
@users = User.find :all, :order => "id DESC"
end

# receives the new user form post
def create
@user = User.new(params[:user])
Expand Down
8 changes: 7 additions & 1 deletion app/views/events/index.html.erb
Expand Up @@ -18,11 +18,14 @@
<div class="yui-u first">
<h2><img src="/images/phone.png" class="icon"> Users inscritos</h2>
<ul>
<%= render :partial => "user", :collection => @users %>
<%= render :partial => "users/user", :collection => @users %>
<% if @users.empty? %>
<li>nenhum. ainda :)</li>
<% end %>
</ul>
<% if @user_count > 10 %>
<a href="/users">Ver a lista completa</a>
<% end %>
</div>
<div class="yui-u">
<h2><img src="/images/text.png" class="icon"> Sessões propostas</h2>
Expand All @@ -32,4 +35,7 @@
<li>nenhuma. ainda :)</li>
<% end %>
</ul>
<% if @talk_count > 4 %>
<a href="/talks">Ver a lista completa</a>
<% end %>
</div>
File renamed without changes.
7 changes: 7 additions & 0 deletions app/views/users/index.html.erb
@@ -0,0 +1,7 @@
<h2><img src="/images/phone.png" class="icon"> Users inscritos</h2>
<ul>
<%= render :partial => "users/user", :collection => @users %>
<% if @users.empty? %>
<li>nenhum. ainda :)</li>
<% end %>
</ul>

0 comments on commit c08ecdd

Please sign in to comment.