active_mocker 1.2.pre → 1.2.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_mocker/version.rb +1 -1
- data/sample_app_rails_4/.idea/.generators +8 -0
- data/sample_app_rails_4/.idea/.name +1 -0
- data/sample_app_rails_4/.idea/.rakeTasks +7 -0
- data/sample_app_rails_4/.idea/dataSources.ids +141 -0
- data/sample_app_rails_4/.idea/dataSources.xml +36 -0
- data/sample_app_rails_4/.idea/dictionaries/zeisler.xml +3 -0
- data/sample_app_rails_4/.idea/encodings.xml +5 -0
- data/sample_app_rails_4/.idea/inspectionProfiles/Project_Default.xml +20 -0
- data/sample_app_rails_4/.idea/inspectionProfiles/profiles_settings.xml +7 -0
- data/sample_app_rails_4/.idea/misc.xml +5 -0
- data/sample_app_rails_4/.idea/modules.xml +10 -0
- data/sample_app_rails_4/.idea/runConfigurations/Development__sample_app_rails_4.xml +28 -0
- data/sample_app_rails_4/.idea/runConfigurations/Production__sample_app_rails_4.xml +28 -0
- data/sample_app_rails_4/.idea/runConfigurations/spec__sample_app_rails_4.xml +26 -0
- data/sample_app_rails_4/.idea/runConfigurations/test__sample_app_rails_4.xml +28 -0
- data/sample_app_rails_4/.idea/sample_app_rails_4.iml +262 -0
- data/sample_app_rails_4/.idea/scopes/scope_settings.xml +5 -0
- data/sample_app_rails_4/.idea/vcs.xml +7 -0
- data/sample_app_rails_4/.idea/workspace.xml +969 -0
- data/sample_app_rails_4/.rspec +1 -0
- data/sample_app_rails_4/.secret +1 -0
- data/sample_app_rails_4/Gemfile +53 -0
- data/sample_app_rails_4/Guardfile +53 -0
- data/sample_app_rails_4/LICENSE +21 -0
- data/sample_app_rails_4/README.md +25 -0
- data/sample_app_rails_4/README.nitrous.md +20 -0
- data/sample_app_rails_4/Rakefile +6 -0
- data/sample_app_rails_4/app/assets/images/rails.png +0 -0
- data/sample_app_rails_4/app/assets/javascripts/application.js +17 -0
- data/sample_app_rails_4/app/assets/javascripts/sessions.js.coffee +3 -0
- data/sample_app_rails_4/app/assets/javascripts/static_pages.js.coffee +3 -0
- data/sample_app_rails_4/app/assets/javascripts/users.js.coffee +3 -0
- data/sample_app_rails_4/app/assets/stylesheets/application.css +13 -0
- data/sample_app_rails_4/app/assets/stylesheets/custom.css.scss +246 -0
- data/sample_app_rails_4/app/assets/stylesheets/sessions.css.scss +3 -0
- data/sample_app_rails_4/app/assets/stylesheets/static_pages.css.scss +3 -0
- data/sample_app_rails_4/app/assets/stylesheets/users.css.scss +3 -0
- data/sample_app_rails_4/app/controllers/application_controller.rb +6 -0
- data/sample_app_rails_4/app/controllers/concerns/.keep +0 -0
- data/sample_app_rails_4/app/controllers/microposts_controller.rb +31 -0
- data/sample_app_rails_4/app/controllers/relationships_controller.rb +21 -0
- data/sample_app_rails_4/app/controllers/sessions_controller.rb +21 -0
- data/sample_app_rails_4/app/controllers/static_pages_controller.rb +18 -0
- data/sample_app_rails_4/app/controllers/users_controller.rb +80 -0
- data/sample_app_rails_4/app/helpers/application_helper.rb +12 -0
- data/sample_app_rails_4/app/helpers/sessions_helper.rb +49 -0
- data/sample_app_rails_4/app/helpers/static_pages_helper.rb +2 -0
- data/sample_app_rails_4/app/helpers/users_helper.rb +10 -0
- data/sample_app_rails_4/app/mailers/.keep +0 -0
- data/sample_app_rails_4/app/models/.keep +0 -0
- data/sample_app_rails_4/app/models/concerns/.keep +0 -0
- data/sample_app_rails_4/app/models/micropost.rb +14 -0
- data/sample_app_rails_4/app/models/relationship.rb +6 -0
- data/sample_app_rails_4/app/models/user.rb +47 -0
- data/sample_app_rails_4/app/views/layouts/_footer.html.erb +13 -0
- data/sample_app_rails_4/app/views/layouts/_header.html.erb +31 -0
- data/sample_app_rails_4/app/views/layouts/_shim.html.erb +3 -0
- data/sample_app_rails_4/app/views/layouts/application.html.erb +22 -0
- data/sample_app_rails_4/app/views/microposts/_micropost.html.erb +11 -0
- data/sample_app_rails_4/app/views/relationships/create.js.erb +2 -0
- data/sample_app_rails_4/app/views/relationships/destroy.js.erb +2 -0
- data/sample_app_rails_4/app/views/sessions/new.html.erb +19 -0
- data/sample_app_rails_4/app/views/shared/_error_messages.html.erb +12 -0
- data/sample_app_rails_4/app/views/shared/_feed.html.erb +6 -0
- data/sample_app_rails_4/app/views/shared/_feed_item.html.erb +15 -0
- data/sample_app_rails_4/app/views/shared/_micropost_form.html.erb +7 -0
- data/sample_app_rails_4/app/views/shared/_stats.html.erb +15 -0
- data/sample_app_rails_4/app/views/shared/_user_info.html.erb +12 -0
- data/sample_app_rails_4/app/views/static_pages/about.html.erb +8 -0
- data/sample_app_rails_4/app/views/static_pages/contact.html.erb +6 -0
- data/sample_app_rails_4/app/views/static_pages/help.html.erb +8 -0
- data/sample_app_rails_4/app/views/static_pages/home.html.erb +34 -0
- data/sample_app_rails_4/app/views/static_pages/show.html.erb +0 -0
- data/sample_app_rails_4/app/views/users/_follow.html.erb +5 -0
- data/sample_app_rails_4/app/views/users/_follow_form.html.erb +9 -0
- data/sample_app_rails_4/app/views/users/_unfollow.html.erb +5 -0
- data/sample_app_rails_4/app/views/users/_user.html.erb +8 -0
- data/sample_app_rails_4/app/views/users/edit.html.erb +27 -0
- data/sample_app_rails_4/app/views/users/index.html.erb +10 -0
- data/sample_app_rails_4/app/views/users/new.html.erb +24 -0
- data/sample_app_rails_4/app/views/users/show.html.erb +24 -0
- data/sample_app_rails_4/app/views/users/show_follow.html.erb +30 -0
- data/sample_app_rails_4/bin/bundle +3 -0
- data/sample_app_rails_4/bin/rails +4 -0
- data/sample_app_rails_4/bin/rake +4 -0
- data/sample_app_rails_4/config.ru +4 -0
- data/sample_app_rails_4/config/application.rb +31 -0
- data/sample_app_rails_4/config/boot.rb +4 -0
- data/sample_app_rails_4/config/cucumber.yml +8 -0
- data/sample_app_rails_4/config/database.yml +28 -0
- data/sample_app_rails_4/config/environment.rb +5 -0
- data/sample_app_rails_4/config/environments/development.rb +27 -0
- data/sample_app_rails_4/config/environments/production.rb +79 -0
- data/sample_app_rails_4/config/environments/test.rb +39 -0
- data/sample_app_rails_4/config/initializers/active_mocker.rb +10 -0
- data/sample_app_rails_4/config/initializers/backtrace_silencers.rb +7 -0
- data/sample_app_rails_4/config/initializers/filter_parameter_logging.rb +4 -0
- data/sample_app_rails_4/config/initializers/inflections.rb +16 -0
- data/sample_app_rails_4/config/initializers/mime_types.rb +5 -0
- data/sample_app_rails_4/config/initializers/secret_token.rb +22 -0
- data/sample_app_rails_4/config/initializers/session_store.rb +3 -0
- data/sample_app_rails_4/config/initializers/wrap_parameters.rb +14 -0
- data/sample_app_rails_4/config/locales/en.yml +23 -0
- data/sample_app_rails_4/config/routes.rb +17 -0
- data/sample_app_rails_4/db/development.sqlite3 +0 -0
- data/sample_app_rails_4/db/migrate/20130311191400_create_users.rb +10 -0
- data/sample_app_rails_4/db/migrate/20130311194153_add_index_to_users_email.rb +5 -0
- data/sample_app_rails_4/db/migrate/20130311201841_add_password_digest_to_users.rb +5 -0
- data/sample_app_rails_4/db/migrate/20130314184954_add_remember_token_to_users.rb +6 -0
- data/sample_app_rails_4/db/migrate/20130315015932_add_admin_to_users.rb +5 -0
- data/sample_app_rails_4/db/migrate/20130315175534_create_microposts.rb +11 -0
- data/sample_app_rails_4/db/migrate/20130315230445_create_relationships.rb +13 -0
- data/sample_app_rails_4/db/schema.rb +49 -0
- data/sample_app_rails_4/db/seeds.rb +7 -0
- data/sample_app_rails_4/db/test.sqlite3 +0 -0
- data/sample_app_rails_4/features/signing_in.feature +13 -0
- data/sample_app_rails_4/features/step_definitions/authentication_steps.rb +30 -0
- data/sample_app_rails_4/features/support/env.rb +59 -0
- data/sample_app_rails_4/lib/assets/.keep +0 -0
- data/sample_app_rails_4/lib/tasks/.keep +0 -0
- data/sample_app_rails_4/lib/tasks/cucumber.rake +65 -0
- data/sample_app_rails_4/lib/tasks/mocks.rake +10 -0
- data/sample_app_rails_4/lib/tasks/sample_data.rake +42 -0
- data/sample_app_rails_4/log/.keep +0 -0
- data/sample_app_rails_4/log/development.log +603 -0
- data/sample_app_rails_4/log/test.log +6727 -0
- data/sample_app_rails_4/public/404.html +27 -0
- data/sample_app_rails_4/public/422.html +26 -0
- data/sample_app_rails_4/public/500.html +26 -0
- data/sample_app_rails_4/public/assets/application-4962059d8f80f9bb096692bacc29c4e8.css +5091 -0
- data/sample_app_rails_4/public/assets/application-4962059d8f80f9bb096692bacc29c4e8.css.gz +0 -0
- data/sample_app_rails_4/public/assets/application-eeb856e3fe2c8f879c91d0e81d59cb40.js +12952 -0
- data/sample_app_rails_4/public/assets/application-eeb856e3fe2c8f879c91d0e81d59cb40.js.gz +0 -0
- data/sample_app_rails_4/public/assets/glyphicons-halflings-c806376f05e4ccabe2c5315a8e95667c.png +0 -0
- data/sample_app_rails_4/public/assets/glyphicons-halflings-white-62b67d9edee3db90d18833087f848d6e.png +0 -0
- data/sample_app_rails_4/public/assets/manifest-802de9eb1c853769101852422b620883.json +1 -0
- data/sample_app_rails_4/public/assets/rails-231a680f23887d9dd70710ea5efd3c62.png +0 -0
- data/sample_app_rails_4/public/favicon.ico +0 -0
- data/sample_app_rails_4/public/robots.txt +5 -0
- data/sample_app_rails_4/script/cucumber +10 -0
- data/sample_app_rails_4/spec/controllers/relationships_controller_spec.rb +42 -0
- data/sample_app_rails_4/spec/factories.rb +17 -0
- data/sample_app_rails_4/spec/helpers/application_helper_spec.rb +18 -0
- data/sample_app_rails_4/spec/models/micropost_spec.rb +30 -0
- data/sample_app_rails_4/spec/models/relationship_spec.rb +29 -0
- data/sample_app_rails_4/spec/models/user_spec.rb +194 -0
- data/sample_app_rails_4/spec/spec_helper.rb +49 -0
- data/sample_app_rails_4/spec/support/utilities.rb +21 -0
- data/sample_app_rails_4/vendor/assets/javascripts/.keep +0 -0
- data/sample_app_rails_4/vendor/assets/stylesheets/.keep +0 -0
- metadata +151 -1
File without changes
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class MicropostsController < ApplicationController
|
2
|
+
before_action :signed_in_user, only: [:create, :destroy]
|
3
|
+
before_action :correct_user, only: :destroy
|
4
|
+
|
5
|
+
def create
|
6
|
+
@micropost = current_user.microposts.build(micropost_params)
|
7
|
+
if @micropost.save
|
8
|
+
flash[:success] = "Micropost created!"
|
9
|
+
redirect_to root_url
|
10
|
+
else
|
11
|
+
@feed_items = []
|
12
|
+
render 'static_pages/home'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def destroy
|
17
|
+
@micropost.destroy
|
18
|
+
redirect_to root_url
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def micropost_params
|
24
|
+
params.require(:micropost).permit(:content)
|
25
|
+
end
|
26
|
+
|
27
|
+
def correct_user
|
28
|
+
@micropost = current_user.microposts.find_by(id: params[:id])
|
29
|
+
redirect_to root_url if @micropost.nil?
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class RelationshipsController < ApplicationController
|
2
|
+
before_action :signed_in_user
|
3
|
+
|
4
|
+
def create
|
5
|
+
@user = User.find(params[:relationship][:followed_id])
|
6
|
+
current_user.follow!(@user)
|
7
|
+
respond_to do |format|
|
8
|
+
format.html { redirect_to @user }
|
9
|
+
format.js
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def destroy
|
14
|
+
@user = Relationship.find(params[:id]).followed
|
15
|
+
current_user.unfollow!(@user)
|
16
|
+
respond_to do |format|
|
17
|
+
format.html { redirect_to @user }
|
18
|
+
format.js
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class SessionsController < ApplicationController
|
2
|
+
|
3
|
+
def new
|
4
|
+
end
|
5
|
+
|
6
|
+
def create
|
7
|
+
user = User.find_by(email: params[:session][:email].downcase)
|
8
|
+
if user && user.authenticate(params[:session][:password])
|
9
|
+
sign_in user
|
10
|
+
redirect_back_or user
|
11
|
+
else
|
12
|
+
flash.now[:error] = 'Invalid email/password combination'
|
13
|
+
render 'new'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def destroy
|
18
|
+
sign_out
|
19
|
+
redirect_to root_url
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class StaticPagesController < ApplicationController
|
2
|
+
|
3
|
+
def home
|
4
|
+
if signed_in?
|
5
|
+
@micropost = current_user.microposts.build
|
6
|
+
@feed_items = current_user.feed.paginate(page: params[:page])
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def help
|
11
|
+
end
|
12
|
+
|
13
|
+
def about
|
14
|
+
end
|
15
|
+
|
16
|
+
def contact
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
class UsersController < ApplicationController
|
2
|
+
before_action :signed_in_user,
|
3
|
+
only: [:index, :edit, :update, :destroy, :following, :followers]
|
4
|
+
before_action :correct_user, only: [:edit, :update]
|
5
|
+
before_action :admin_user, only: :destroy
|
6
|
+
|
7
|
+
def index
|
8
|
+
@users = User.paginate(page: params[:page])
|
9
|
+
end
|
10
|
+
|
11
|
+
def show
|
12
|
+
@user = User.find(params[:id])
|
13
|
+
@microposts = @user.microposts.paginate(page: params[:page])
|
14
|
+
end
|
15
|
+
|
16
|
+
def new
|
17
|
+
@user = User.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def create
|
21
|
+
@user = User.new(user_params)
|
22
|
+
if @user.save
|
23
|
+
sign_in @user
|
24
|
+
flash[:success] = "Welcome to the Sample App!"
|
25
|
+
redirect_to @user
|
26
|
+
else
|
27
|
+
render 'new'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def edit
|
32
|
+
end
|
33
|
+
|
34
|
+
def update
|
35
|
+
if @user.update_attributes(user_params)
|
36
|
+
flash[:success] = "Profile updated"
|
37
|
+
redirect_to @user
|
38
|
+
else
|
39
|
+
render 'edit'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def destroy
|
44
|
+
User.find(params[:id]).destroy
|
45
|
+
flash[:success] = "User destroyed."
|
46
|
+
redirect_to users_url
|
47
|
+
end
|
48
|
+
|
49
|
+
def following
|
50
|
+
@title = "Following"
|
51
|
+
@user = User.find(params[:id])
|
52
|
+
@users = @user.followed_users.paginate(page: params[:page])
|
53
|
+
render 'show_follow'
|
54
|
+
end
|
55
|
+
|
56
|
+
def followers
|
57
|
+
@title = "Followers"
|
58
|
+
@user = User.find(params[:id])
|
59
|
+
@users = @user.followers.paginate(page: params[:page])
|
60
|
+
render 'show_follow'
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def user_params
|
66
|
+
params.require(:user).permit(:name, :email, :password,
|
67
|
+
:password_confirmation)
|
68
|
+
end
|
69
|
+
|
70
|
+
# Before filters
|
71
|
+
|
72
|
+
def correct_user
|
73
|
+
@user = User.find(params[:id])
|
74
|
+
redirect_to(root_url) unless current_user?(@user)
|
75
|
+
end
|
76
|
+
|
77
|
+
def admin_user
|
78
|
+
redirect_to(root_url) unless current_user.admin?
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module SessionsHelper
|
2
|
+
|
3
|
+
def sign_in(user)
|
4
|
+
remember_token = User.new_remember_token
|
5
|
+
cookies.permanent[:remember_token] = remember_token
|
6
|
+
user.update_attribute(:remember_token, User.digest(remember_token))
|
7
|
+
self.current_user = user
|
8
|
+
end
|
9
|
+
|
10
|
+
def signed_in?
|
11
|
+
!current_user.nil?
|
12
|
+
end
|
13
|
+
|
14
|
+
def current_user=(user)
|
15
|
+
@current_user = user
|
16
|
+
end
|
17
|
+
|
18
|
+
def current_user
|
19
|
+
remember_token = User.digest(cookies[:remember_token])
|
20
|
+
@current_user ||= User.find_by(remember_token: remember_token)
|
21
|
+
end
|
22
|
+
|
23
|
+
def current_user?(user)
|
24
|
+
user == current_user
|
25
|
+
end
|
26
|
+
|
27
|
+
def signed_in_user
|
28
|
+
unless signed_in?
|
29
|
+
store_location
|
30
|
+
redirect_to signin_url, notice: "Please sign in."
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def sign_out
|
35
|
+
current_user.update_attribute(:remember_token,
|
36
|
+
User.digest(User.new_remember_token))
|
37
|
+
cookies.delete(:remember_token)
|
38
|
+
self.current_user = nil
|
39
|
+
end
|
40
|
+
|
41
|
+
def redirect_back_or(default)
|
42
|
+
redirect_to(session[:return_to] || default)
|
43
|
+
session.delete(:return_to)
|
44
|
+
end
|
45
|
+
|
46
|
+
def store_location
|
47
|
+
session[:return_to] = request.url if request.get?
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module UsersHelper
|
2
|
+
|
3
|
+
# Returns the Gravatar (http://gravatar.com/) for the given user.
|
4
|
+
def gravatar_for(user, options = { size: 50 })
|
5
|
+
gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
|
6
|
+
size = options[:size]
|
7
|
+
gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{size}"
|
8
|
+
image_tag(gravatar_url, alt: user.name, class: "gravatar")
|
9
|
+
end
|
10
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Micropost < ActiveRecord::Base
|
2
|
+
belongs_to :user
|
3
|
+
default_scope -> { order('created_at DESC') }
|
4
|
+
validates :content, presence: true, length: { maximum: 140 }
|
5
|
+
validates :user_id, presence: true
|
6
|
+
|
7
|
+
# Returns microposts from the users being followed by the given user.
|
8
|
+
def self.from_users_followed_by(user)
|
9
|
+
followed_user_ids = "SELECT followed_id FROM relationships
|
10
|
+
WHERE follower_id = :user_id"
|
11
|
+
where("user_id IN (#{followed_user_ids}) OR user_id = :user_id",
|
12
|
+
user_id: user.id)
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
class User < ActiveRecord::Base
|
2
|
+
has_many :microposts, dependent: :destroy
|
3
|
+
has_many :relationships, foreign_key: "follower_id", dependent: :destroy
|
4
|
+
has_many :followed_users, through: :relationships, source: :followed
|
5
|
+
has_many :reverse_relationships, foreign_key: "followed_id",
|
6
|
+
class_name: "Relationship",
|
7
|
+
dependent: :destroy
|
8
|
+
has_many :followers, through: :reverse_relationships, source: :follower
|
9
|
+
before_save { self.email = email.downcase }
|
10
|
+
before_create :create_remember_token
|
11
|
+
validates :name, presence: true, length: { maximum: 50 }
|
12
|
+
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
|
13
|
+
validates :email, presence: true, format: { with: VALID_EMAIL_REGEX },
|
14
|
+
uniqueness: { case_sensitive: false }
|
15
|
+
has_secure_password
|
16
|
+
validates :password, length: { minimum: 6 }
|
17
|
+
|
18
|
+
def User.new_remember_token
|
19
|
+
SecureRandom.urlsafe_base64
|
20
|
+
end
|
21
|
+
|
22
|
+
def User.digest(token)
|
23
|
+
Digest::SHA1.hexdigest(token.to_s)
|
24
|
+
end
|
25
|
+
|
26
|
+
def feed
|
27
|
+
Micropost.from_users_followed_by(self)
|
28
|
+
end
|
29
|
+
|
30
|
+
def following?(other_user)
|
31
|
+
relationships.find_by(followed_id: other_user.id)
|
32
|
+
end
|
33
|
+
|
34
|
+
def follow!(other_user)
|
35
|
+
relationships.create!(followed_id: other_user.id)
|
36
|
+
end
|
37
|
+
|
38
|
+
def unfollow!(other_user)
|
39
|
+
relationships.find_by(followed_id: other_user.id).destroy
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def create_remember_token
|
45
|
+
self.remember_token = User.digest(User.new_remember_token)
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<footer class="footer">
|
2
|
+
<small>
|
3
|
+
<a href="http://railstutorial.org/">Rails Tutorial</a>
|
4
|
+
by Michael Hartl
|
5
|
+
</small>
|
6
|
+
<nav>
|
7
|
+
<ul>
|
8
|
+
<li><%= link_to "About", about_path %></li>
|
9
|
+
<li><%= link_to "Contact", contact_path %></li>
|
10
|
+
<li><a href="http://news.railstutorial.org/">News</a></li>
|
11
|
+
</ul>
|
12
|
+
</nav>
|
13
|
+
</footer>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<header class="navbar navbar-fixed-top navbar-inverse">
|
2
|
+
<div class="navbar-inner">
|
3
|
+
<div class="container">
|
4
|
+
<%= link_to "sample app", root_path, id: "logo" %>
|
5
|
+
<nav>
|
6
|
+
<ul class="nav pull-right">
|
7
|
+
<li><%= link_to "Home", root_path %></li>
|
8
|
+
<li><%= link_to "Help", help_path %></li>
|
9
|
+
<% if signed_in? %>
|
10
|
+
<li><%= link_to "Users", users_path %></li>
|
11
|
+
<li id="fat-menu" class="dropdown">
|
12
|
+
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
13
|
+
Account <b class="caret"></b>
|
14
|
+
</a>
|
15
|
+
<ul class="dropdown-menu">
|
16
|
+
<li><%= link_to "Profile", current_user %></li>
|
17
|
+
<li><%= link_to "Settings", edit_user_path(current_user) %></li>
|
18
|
+
<li class="divider"></li>
|
19
|
+
<li>
|
20
|
+
<%= link_to "Sign out", signout_path, method: "delete" %>
|
21
|
+
</li>
|
22
|
+
</ul>
|
23
|
+
</li>
|
24
|
+
<% else %>
|
25
|
+
<li><%= link_to "Sign in", signin_path %></li>
|
26
|
+
<% end %>
|
27
|
+
</ul>
|
28
|
+
</nav>
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
</header>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title><%= full_title(yield(:title)) %></title>
|
5
|
+
<%= stylesheet_link_tag "application", media: "all",
|
6
|
+
"data-turbolinks-track" => true %>
|
7
|
+
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
|
8
|
+
<%= csrf_meta_tags %>
|
9
|
+
<%= render 'layouts/shim' %>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<%= render 'layouts/header' %>
|
13
|
+
<div class="container">
|
14
|
+
<% flash.each do |key, value| %>
|
15
|
+
<div class="alert alert-<%= key %>"><%= value %></div>
|
16
|
+
<% end %>
|
17
|
+
<%= yield %>
|
18
|
+
<%= render 'layouts/footer' %>
|
19
|
+
<%= debug(params) if Rails.env.development? %>
|
20
|
+
</div>
|
21
|
+
</body>
|
22
|
+
</html>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<li>
|
2
|
+
<span class="content"><%= micropost.content %></span>
|
3
|
+
<span class="timestamp">
|
4
|
+
Posted <%= time_ago_in_words(micropost.created_at) %> ago.
|
5
|
+
</span>
|
6
|
+
<% if current_user?(micropost.user) %>
|
7
|
+
<%= link_to "delete", micropost, method: :delete,
|
8
|
+
data: { confirm: "You sure?" },
|
9
|
+
title: micropost.content %>
|
10
|
+
<% end %>
|
11
|
+
</li>
|