Skip to content

Instantly share code, notes, and snippets.

@kareemgrant
Created February 24, 2015 00:35
Show Gist options
  • Save kareemgrant/fef5c760803fd7506c24 to your computer and use it in GitHub Desktop.
Save kareemgrant/fef5c760803fd7506c24 to your computer and use it in GitHub Desktop.
<h1>Here's some info about one user:</h1>
<ul>
<li>Id: <%= @user.id %></li>
<li>Name: <%= @user.name %></li>
<li>Email: <%= @user.email %></li>
<li>Phone: <%= @user.phone %></li>
</ul>
<h3>Posts</h3>
<ul>
<% @posts.each do |post| %>
<li><%= post.title %></li>
<% end %>
</ul>
class UsersController < ApplicationController
def index
@users = User.all
end
def show
@user = User.find_by_id(params[:id])
@posts = @user.posts
end
def destroy
@user = User.find_by_id(params[:id])
@student.destroy
flash[:notice] = "This user was deleted."
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment