diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 5f864a0..6bed09d 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -21,4 +21,8 @@ body{ h1{ font-size:1.8em; color:#333; -} \ No newline at end of file +} + +td{ + padding: 10px; +} diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3e74dea..bd3d37e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,2 +1,20 @@ 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_path + else + render :new + end + end + end diff --git a/app/views/users/_user.html.erb b/app/views/users/_user.html.erb new file mode 100644 index 0000000..4068de0 --- /dev/null +++ b/app/views/users/_user.html.erb @@ -0,0 +1,4 @@ + + <%= user.name %> + <%= user.email %> + diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb new file mode 100644 index 0000000..f09fe45 --- /dev/null +++ b/app/views/users/index.html.erb @@ -0,0 +1,5 @@ + +<%= render @users %> +
+ +<%= link_to "Create new", new_user_path %> diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb new file mode 100644 index 0000000..cc0c57e --- /dev/null +++ b/app/views/users/new.html.erb @@ -0,0 +1,9 @@ +<%= form_for @user do |f| %> + <%= f.label :name %> + <%= f.text_field :name %> + <%= @user.errors.get(:name).join(', ') %> + <%= f.label :email %> + <%= f.text_field :email %> + <%= @user.errors.get(:email).join(', ') %> + <%= f.submit %> +<% end %> diff --git a/config/routes.rb b/config/routes.rb index 938145e..364cfc6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,6 +3,7 @@ # first created -> highest priority. resources :todos + resources :users # Sample of regular route: # match 'products/:id' => 'catalog#view'