Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setup sample data, users index with pagination
- Loading branch information
paws
committed
Dec 13, 2011
1 parent
149c828
commit 4ae206f
Showing
8 changed files
with
68 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<li> | ||
<%= gravatar_for user, :size => 25 %> | ||
<%= link_to user.name, user %> | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
<h1>All users</h1> | ||
|
||
<%= will_paginate %> | ||
<%# will_paginate in a given controller automatically looks for an instance variable of the same name %> | ||
<ul class="users"> | ||
<% @users.each do |user| %> | ||
<li> | ||
<%= gravatar_for user, :size => 25 %> | ||
<%= link_to user.name, user %> | ||
</li> | ||
<% end %> | ||
|
||
<%# METHOD 3 - works as long as its enumerable (can run .each) %> | ||
<%= render @users %> | ||
<%# @users.each do |user| %> | ||
<%# METHOD 1 %> | ||
<%#= render 'user', :user => user #manually coding it %> | ||
<%# METHOD 2 %> | ||
<%#= render user %> | ||
<%# yes, somehow rails knows to render the _user partial AND pass the user variable %> | ||
<%# end %> | ||
</ul> | ||
<%= will_paginate %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'faker' | ||
|
||
namespace :db do | ||
desc 'Fill database with sample data' | ||
task :populate => :environment do | ||
Rake::Task['db:reset'].invoke #runs rake db:reset to clear database | ||
User.create!(:name => "Example User", | ||
:email => "example@e.org", | ||
:password => "foobar", | ||
:password_confirmation => "foobar") | ||
99.times do |n| | ||
name = Faker::Name.name | ||
email = "example-#{n+1}@railstutorial.org" | ||
password = "boring" | ||
User.create!(:name => name, | ||
:email => email, | ||
:password => password, | ||
:password_confirmation => password) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters