Skip to content

Commit

Permalink
add user profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
rmi22186 committed Sep 17, 2013
1 parent a753f07 commit f8c1e7b
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/assets/javascripts/users.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/users.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Users controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
6 changes: 6 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class UsersController < ApplicationController
def show
@user = User.find(params[:id])
@pins = @user.pins.page(params[:page]).per_page(20)
end
end
2 changes: 2 additions & 0 deletions app/helpers/users_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module UsersHelper
end
2 changes: 1 addition & 1 deletion app/views/pins/_pin.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<%= pin.description %>
</p>
<strong>
Posted by <%= pin.user.name%>
Posted by <%= link_to pin.user.name, pin.user %>
</strong>
<p>
<% if current_user == pin.user %>
Expand Down
7 changes: 7 additions & 0 deletions app/views/users/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<h1><%= @user.name %></h1>

<div id="pins">
<%= render @pins %>
</div>

<%= will_paginate @pins %>
5 changes: 5 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
Omrails::Application.routes.draw do
get "users/show"

resources :pins


devise_for :users
match 'users/:id' => 'users#show', as: :user


get 'about' => 'pages#about'
root :to => 'pins#index'



# The priority is based upon order of creation:
# first created -> highest priority.

Expand Down
9 changes: 9 additions & 0 deletions test/functional/users_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'test_helper'

class UsersControllerTest < ActionController::TestCase
test "should get show" do
get :show
assert_response :success
end

end
4 changes: 4 additions & 0 deletions test/unit/helpers/users_helper_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require 'test_helper'

class UsersHelperTest < ActionView::TestCase
end

0 comments on commit f8c1e7b

Please sign in to comment.