parent
b86d78fac0
commit
ca39eea326
@ -0,0 +1,5 @@ |
||||
class ProfilesController < ApplicationController |
||||
def show |
||||
@profile = Profile.find params[:id] |
||||
end |
||||
end |
@ -1,3 +1,7 @@ |
||||
class Profile < ApplicationRecord |
||||
has_many :posts |
||||
|
||||
def full_name |
||||
[first_name, last_name].map(&:presence).compact.join ' ' |
||||
end |
||||
end |
||||
|
@ -0,0 +1,11 @@ |
||||
<h1><%= @profile.full_name %></h1> |
||||
|
||||
<p><%= @profile.description %></p> |
||||
|
||||
<% if @profile.posts.present? %> |
||||
<ul> |
||||
<% @profile.posts.each do |post| %> |
||||
<li><%= post.text %></li> |
||||
<% end %> |
||||
</ul> |
||||
<% end %> |
@ -1,4 +1,5 @@ |
||||
Rails.application.routes.draw do |
||||
get 'home/show' |
||||
root to: 'home#show' |
||||
|
||||
resources :profiles, only: :show |
||||
end |
||||
|
@ -0,0 +1,8 @@ |
||||
require "test_helper" |
||||
|
||||
class ProfilesControllerTest < ActionDispatch::IntegrationTest |
||||
test "should get show" do |
||||
get profiles_show_url |
||||
assert_response :success |
||||
end |
||||
end |
Reference in new issue