Permalink
Browse files

adds 'spiral_name' method. adds @Admin replies to sample data

  • Loading branch information...
jholton committed Mar 29, 2013
1 parent a3d1885 commit f1cf767576cd4962a795519dbbf877450e31b8aa
Showing with 15 additions and 5 deletions.
  1. +5 −1 app/models/user.rb
  2. +4 −1 app/views/shared/_user_info.html.erb
  3. +1 −1 app/views/users/show.html.erb
  4. +5 −2 lib/tasks/sample_data.rake
View
@@ -28,7 +28,7 @@ class User < ActiveRecord::Base
uniqueness: true
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
- validates :email, presence: true,
+ validates :email, presence: true,
format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sensitive: false }
validates :password, presence: true, length: { minimum: 6 }
@@ -51,6 +51,10 @@ def unfollow!(other_user)
relationships.find_by_followed_id(other_user.id).destroy
end
+ def spiral_name
+ "@#{username}"
+ end
+
private
def create_remember_token
@@ -2,8 +2,11 @@
<%= gravatar_for current_user, size: 52 %>
</a>
<h1>
- <%= current_user.name %>
+ <%= current_user.spiral_name %>
</h1>
+<p1>
+ <%= current_user.name %>
+</p1>
<span>
<%= link_to "view my profile", current_user %>
</span>
@@ -4,7 +4,7 @@
<section>
<h1>
<%= gravatar_for @user %>
- <%= @user.username %>
+ <%= @user.spiral_name %>
</h1>
<p1>
<%= @user.name %>
@@ -16,7 +16,7 @@ def make_users
admin.toggle!(:admin)
99.times do |n|
name = Faker::Name.name
- username = Faker::Name.name
+ username = Faker::Name.name.gsub(" ","_")
email = "example-#{n+1}@railstutorial.org"
password = "password"
User.create!(name: name,
@@ -29,8 +29,11 @@ end
def make_microposts
users = User.all(limit: 6)
- 50.times do
+ 50.times do |n|
content = Faker::Lorem.sentence(5)
+ if (n+1)%10 == 0
+ content = "@Admin #{content}"
+ end
users.each { |user| user.microposts.create!(content: content) }
end
end

0 comments on commit f1cf767

Please sign in to comment.