-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate resource user. Added datamapper database.yml.
- Loading branch information
Showing
13 changed files
with
157 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
class Users < Application | ||
# provides :xml, :yaml, :js | ||
|
||
def index | ||
@users = User.all | ||
display @users | ||
end | ||
|
||
def show | ||
@user = User.get(params[:id]) | ||
raise NotFound unless @user | ||
display @user | ||
end | ||
|
||
def new | ||
only_provides :html | ||
@user = User.new | ||
render | ||
end | ||
|
||
def edit | ||
only_provides :html | ||
@user = User.get(params[:id]) | ||
raise NotFound unless @user | ||
render | ||
end | ||
|
||
def create | ||
@user = User.new(params[:user]) | ||
if @user.save | ||
redirect url(:user, @user) | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
def update | ||
@user = User.get(params[:id]) | ||
raise NotFound unless @user | ||
if @user.update_attributes(params[:user]) || !@user.dirty? | ||
redirect url(:user, @user) | ||
else | ||
raise BadRequest | ||
end | ||
end | ||
|
||
def destroy | ||
@user = User.get(params[:id]) | ||
raise NotFound unless @user | ||
if @user.destroy | ||
redirect url(:user) | ||
else | ||
raise BadRequest | ||
end | ||
end | ||
|
||
end # Users |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Merb | ||
module UsersHelper | ||
|
||
end | ||
end # Merb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class User | ||
include DataMapper::Resource | ||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<h1>Users controller, edit action</h1> | ||
|
||
<p>Edit this file in <tt>app/views/users/edit.html.erb</tt></p> | ||
|
||
<%= form_for(@user, :action => url(:user, @user)) do %> | ||
<p> | ||
<%= submit "Update" %> | ||
</p> | ||
<% end =%> | ||
|
||
<%= link_to 'Show', url(:user, @user) %> | | ||
<%= link_to 'Back', url(:users) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<h1>Users controller, index action</h1> | ||
|
||
<p>Edit this file in <tt>app/views/users/index.html.erb</tt></p> | ||
|
||
<table> | ||
<tr> | ||
</tr> | ||
|
||
<% for user in @users %> | ||
<tr> | ||
<td><%= link_to 'Show', url(:user, user) %></td> | ||
<td><%= link_to 'Edit', url(:edit_user, user) %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<%= link_to 'New', url(:new_user) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<h1>Users controller, new action</h1> | ||
|
||
<p>Edit this file in <tt>app/views/users/new.html.erb</tt></p> | ||
|
||
<%= form_for(@user, :action => url(:users) ) do %> | ||
<p> | ||
<%= submit "Create" %> | ||
</p> | ||
<% end =%> | ||
|
||
<%= link_to 'Back', url(:users) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<h1>Users controller, show action</h1> | ||
|
||
<p>Edit this file in <tt>app/views/users/show.html.erb</tt></p> | ||
|
||
|
||
<%= link_to 'Edit', url(:edit_user, @user) %> | | ||
<%= link_to 'Back', url(:users) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
:development: &defaults | ||
:adapter: mysql | ||
:database: pool_tracker_dev | ||
:username: pool_tracker | ||
:password: pool_tracker | ||
:host: localhost | ||
|
||
:test: | ||
<<: *defaults | ||
:database: sample_test | ||
|
||
:production: | ||
<<: *defaults | ||
:database: sample_production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') | ||
|
||
describe Users, "index action" do | ||
before(:each) do | ||
dispatch_to(Users, :index) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') | ||
|
||
describe Merb::UsersHelper do | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require File.join( File.dirname(__FILE__), '..', "spec_helper" ) | ||
|
||
describe User do | ||
|
||
it "should have specs" | ||
|
||
end |