Skip to content

Instantly share code, notes, and snippets.

@alan707 alan707/User.rb
Last active Dec 14, 2015

What would you like to do?
<h1>Listing users</h1>
<th>Facebook ID</th>
<th>Facebook Username</th>
<% @users.each do |user| %>
<td><%= user.try(:firstname) %></td>
<td><%= user.try(:lastname) %></td>
<td><%= user.try(:email) %></td>
<td><%= user.try(:facebook_id) %></td>
<td><%= user.try(:facebook_username) %></td>
<td><%= user.try(:username) %></td>
<td><%= link_to 'Show', user %></td>
<td><%= link_to 'Edit', edit_user_path(user) %></td>
<td><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %></td>
<% end %>
<br />
<%= link_to 'New User', new_user_path %>
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
Started GET "/users" for at 2013-03-04 03:54:09 +0000
2013-03-04T03:54:09+00:00 app[web.1]: Processing by UsersController#index as HTML
2013-03-04T03:54:09+00:00 app[web.1]: Rendered users/index.html.erb within layouts/application (6.5ms)
2013-03-04T03:54:09+00:00 app[web.1]: Completed 500 Internal Server Error in 20ms
2013-03-04T03:54:09+00:00 app[web.1]: ActionController::RoutingError (No route matches {:action=>"show", :controller=>"users", :id=>#<User id: 15, firstname: "Jennifer", lastname: "Chaiwitz", email: nil, username: nil, created_at: "2013-03-03 01:15:45", updated_at: "2013-03-03 01:15:45", facebook_username: nil, photo_url: nil, facebook_id: 100005394060476>}):
class User < ActiveRecord::Base
attr_accessible :email, :facebook_id, :firstname, :lastname, :username, :facebook_username, :photo_url
def to_param
def as_json(options={})
{:id =>,
:email =>,
:facebook_id => self.try(:facebook_id),
:firstname => self.firstname,
:lastname => self.lastname,
:username => self.username,
:facebook_username => self.try(:facebook_username),
:photo_url => self.try(:photo_url)
class UsersController < ApplicationController
# GET /users
# GET /users.json
def index
@users = User.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @users }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.