Permalink
Browse files

+index, users, faker

  • Loading branch information...
DarTSeNSe committed Dec 9, 2011
1 parent 2eb50d6 commit 7d11d9ed1dd436b586c95c6890240b8ba4970e6c
@@ -1,6 +1,12 @@
class UsersController < ApplicationController
before_filter :authenticate, :only => [:edit, :update]
before_filter :correct_user, :only => [:edit, :update]
+before_filter :authenticate, :only => [:index, :edit, :update]
+
+ def index
+ @title = "All users"
+ @users = User.all
+ end
def show
@user = User.find(params[:id])
@@ -4,6 +4,7 @@
<ul>
<li><%= link_to "Home", root_path %></li>
<% if signed_in? %>
+ <li><%= link_to "Users", users_path %></li>
<li><%= link_to "Profile", current_user %></li>
<li><%= link_to "Settings", edit_user_path(current_user) %></li>
<% end %>
@@ -0,0 +1,10 @@
+<h1>All users</h1>
+
+<ul class="users">
+ <% @users.each do |user| %>
+ <li>
+ <%= gravatar_for user, :size => 30 %>
+ <%= link_to user.name, user %>
+ </li>
+ <% end %>
+</ul>
View
@@ -0,0 +1,19 @@
+namespace :db do
+ desc "Fill database with sample data"
+ task :populate => :environment do
+ Rake::Task['db:reset'].invoke
+ User.create!(:name => "Sense",
+ :email => "sense8life@gmail.com",
+ :password => "0334818",
+ :password_confirmation => "0334818")
+ 99.times do |n|
+ name = Faker::Name.name
+ email = "example-#{n+1}@railstutorial.org"
+ password = "password"
+ User.create!(:name => name,
+ :email => email,
+ :password => password,
+ :password_confirmation => password)
+ end
+ end
+end

0 comments on commit 7d11d9e

Please sign in to comment.