Skip to content

Commit

Permalink
Add user scaffolds
Browse files Browse the repository at this point in the history
  • Loading branch information
he9lin committed Mar 16, 2013
1 parent 00be2b5 commit 5bf7101
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 241 deletions.
3 changes: 3 additions & 0 deletions app/assets/javascripts/users.js.coffee
@@ -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
@@ -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/
18 changes: 18 additions & 0 deletions app/controllers/users_controller.rb
@@ -0,0 +1,18 @@
class UsersController < ApplicationController
def index
@users = User.all
end

def new
@user = User.new
end

def create
user = User.new params[:user]
if user.save
redirect_to users_url
else
render :new
end
end
end
2 changes: 2 additions & 0 deletions app/helpers/users_helper.rb
@@ -0,0 +1,2 @@
module UsersHelper
end
1 change: 1 addition & 0 deletions app/models/user.rb
@@ -1,3 +1,4 @@
class User < ActiveRecord::Base
attr_accessible :name
validates_presence_of :name
end
1 change: 1 addition & 0 deletions app/views/users/_user.html.erb
@@ -0,0 +1 @@
<%= user.id %>-<%= user.name %>
4 changes: 4 additions & 0 deletions app/views/users/index.html.erb
@@ -0,0 +1,4 @@
<h1>Users</h1>

<%= link_to "New user", new_user_path %>
<%= render @users %>
4 changes: 4 additions & 0 deletions app/views/users/new.html.erb
@@ -0,0 +1,4 @@
<%= form_for @user do |f| %>
<%= f.text_field :name %>
<%= f.submit %>
<% end %>
2 changes: 2 additions & 0 deletions config/routes.rb
@@ -1,4 +1,6 @@
MainApp::Application.routes.draw do
resources :users
root to: "users#index"
# The priority is based upon order of creation:
# first created -> highest priority.

Expand Down
241 changes: 0 additions & 241 deletions public/index.html

This file was deleted.

7 changes: 7 additions & 0 deletions test/functional/users_controller_test.rb
@@ -0,0 +1,7 @@
require 'test_helper'

class UsersControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end
4 changes: 4 additions & 0 deletions test/unit/helpers/users_helper_test.rb
@@ -0,0 +1,4 @@
require 'test_helper'

class UsersHelperTest < ActionView::TestCase
end

0 comments on commit 5bf7101

Please sign in to comment.