Skip to content

Instantly share code, notes, and snippets.

@krainboltgreene
Forked from RyanRusnak/controller
Created August 18, 2011 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krainboltgreene/1153041 to your computer and use it in GitHub Desktop.
Save krainboltgreene/1153041 to your computer and use it in GitHub Desktop.
class UsersController < ApplicationController
# GET /users
# GET /users.xml
def index
@users = User.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @users }
end
end
def leaderboard
@search = User.search(params[:search])
@users = @search.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @users }
end
end
# GET /users/1
# GET /users/1.xml
def show
@user = User.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @user }
end
end
# GET /users/new
# GET /users/new.xml
def new
@user = User.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @user }
end
end
# GET /users/1/edit
def edit
@user = User.find(params[:id])
end
# POST /users
# POST /users.xml
def create
@user = User.find(params[:user_id])
@userpost = @user.userposts.create!(params[:userposts])
redirect_to @user
end
# PUT /users/1
# PUT /users/1.xml
def update
@user = User.find(params[:id])
respond_to do |format|
if @user.update_attributes(params[:user])
format.html { redirect_to(@user, :notice => 'User was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /users/1
# DELETE /users/1.xml
def destroy
@user = User.find(params[:id])
@user.destroy
respond_to do |format|
format.html { redirect_to(users_url) }
format.xml { head :ok }
end
end
end
<p id="notice"><%= notice %></p>
<p>
<b>Username:</b>
<%= @user.username %>
</p>
<p>
<b>Email:</b>
<%= @user.email %>
</p>
<!--
<p>
<b>Crypted password:</b>
<%= @user.crypted_password %>
</p>
<p>
<b>Password salt:</b>
<%= @user.password_salt %>
</p>
<p>
<b>Persistence token:</b>
<%= @user.persistence_token %>
</p>
-->
<p>
<b>Age:</b>
<%= @user.age %>
</p>
<p>
<b>Weight:</b>
<%= @user.weight %>
</p>
<p>
<b>Max bench:</b>
<%= @user.maxBench %>
</p>
<p>
<b>Max Squat:</b>
<%= @user.maxSquat %>
</p>
<p>
<b>Gym:</b>
<%= @user.gym.name %>
</p>
<p>
<%= image_tag @user.photo.url(:small) %>
</p>
<%= link_to 'Edit', edit_user_path(@user) %> |
<%= link_to 'Back', users_path %>
<table>
<tr>
<th>Body</th>
<th></th>
<th></th>
<th></th>
</tr>
<% @user.posts.each do |post| %>
<tr>
<td><%= post.body %></td>
<td><%= link_to 'Show', post %></td>
<td><%= link_to 'Edit', edit_post_path(post) %></td>
<td><%= link_to 'Destroy', post, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New Userpost', new_post_path %>
@krainboltgreene
Copy link
Author

$ brew install tree
$ tree
> big tree of directory
$ tree | grep 'schema'
> show exactly where that file is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment