Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Contains 'spiral_name' method and @Admin replies in sample data. #1

Merged
merged 1 commit into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
6 app/models/user.rb
@@ -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
View
5 app/views/shared/_user_info.html.erb
@@ -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>
View
2  app/views/users/show.html.erb
@@ -4,7 +4,7 @@
<section>
<h1>
<%= gravatar_for @user %>
- <%= @user.username %>
+ <%= @user.spiral_name %>
</h1>
<p1>
<%= @user.name %>
View
7 lib/tasks/sample_data.rake
@@ -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
Something went wrong with that request. Please try again.