Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 1 commit into from

2 participants

Johnny Holton Shannon Cancello
Johnny Holton

No description provided.

Shannon Cancello shannoncancello merged commit f1cf767 into from
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.
6 app/models/user.rb
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
5 app/views/shared/_user_info.html.erb
View
@@ -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>
2  app/views/users/show.html.erb
View
@@ -4,7 +4,7 @@
<section>
<h1>
<%= gravatar_for @user %>
- <%= @user.username %>
+ <%= @user.spiral_name %>
</h1>
<p1>
<%= @user.name %>
7 lib/tasks/sample_data.rake
View
@@ -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.