Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Adjunct Addition with foreign key to Adjunct Types. Added dropd…
…own for new and create. Added text descriptions in list and show
- Loading branch information
omar
committed
Mar 25, 2010
1 parent
9a753e6
commit c7503c8
Showing
15 changed files
with
295 additions
and
2 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,85 @@ | ||
class AdjunctAdditionsController < ApplicationController | ||
# GET /adjunct_additions | ||
# GET /adjunct_additions.xml | ||
def index | ||
@adjunct_additions = AdjunctAddition.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.xml { render :xml => @adjunct_additions } | ||
end | ||
end | ||
|
||
# GET /adjunct_additions/1 | ||
# GET /adjunct_additions/1.xml | ||
def show | ||
@adjunct_addition = AdjunctAddition.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.xml { render :xml => @adjunct_addition } | ||
end | ||
end | ||
|
||
# GET /adjunct_additions/new | ||
# GET /adjunct_additions/new.xml | ||
def new | ||
@adjunct_addition = AdjunctAddition.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.xml { render :xml => @adjunct_addition } | ||
end | ||
end | ||
|
||
# GET /adjunct_additions/1/edit | ||
def edit | ||
@adjunct_addition = AdjunctAddition.find(params[:id]) | ||
end | ||
|
||
# POST /adjunct_additions | ||
# POST /adjunct_additions.xml | ||
def create | ||
@adjunct_addition = AdjunctAddition.new(params[:adjunct_addition]) | ||
|
||
respond_to do |format| | ||
if @adjunct_addition.save | ||
flash[:notice] = 'AdjunctAddition was successfully created.' | ||
format.html { redirect_to(@adjunct_addition) } | ||
format.xml { render :xml => @adjunct_addition, :status => :created, :location => @adjunct_addition } | ||
else | ||
format.html { render :action => "new" } | ||
format.xml { render :xml => @adjunct_addition.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /adjunct_additions/1 | ||
# PUT /adjunct_additions/1.xml | ||
def update | ||
@adjunct_addition = AdjunctAddition.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @adjunct_addition.update_attributes(params[:adjunct_addition]) | ||
flash[:notice] = 'AdjunctAddition was successfully updated.' | ||
format.html { redirect_to(@adjunct_addition) } | ||
format.xml { head :ok } | ||
else | ||
format.html { render :action => "edit" } | ||
format.xml { render :xml => @adjunct_addition.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /adjunct_additions/1 | ||
# DELETE /adjunct_additions/1.xml | ||
def destroy | ||
@adjunct_addition = AdjunctAddition.find(params[:id]) | ||
@adjunct_addition.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to(adjunct_additions_url) } | ||
format.xml { head :ok } | ||
end | ||
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,2 @@ | ||
module AdjunctAdditionsHelper | ||
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,2 @@ | ||
class AdjunctAddition < ActiveRecord::Base | ||
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,28 @@ | ||
<h1>Editing adjunct_addition</h1> | ||
|
||
<% form_for(@adjunct_addition) do |f| %> | ||
<%= f.error_messages %> | ||
|
||
<p> | ||
<%= f.label :adjunct_type_id %><br /> | ||
<%= f.collection_select(:adjunct_type_id, AdjunctType.all, :id, :name) %> <br /> | ||
</p> | ||
<p> | ||
<%= f.label :time %><br /> | ||
<%= f.text_field :time %> | ||
</p> | ||
<p> | ||
<%= f.label :amount %><br /> | ||
<%= f.text_field :amount %> | ||
</p> | ||
<p> | ||
<%= f.label :secondary %><br /> | ||
<%= f.check_box :secondary %> | ||
</p> | ||
<p> | ||
<%= f.submit 'Update' %> | ||
</p> | ||
<% end %> | ||
<%= link_to 'Show', @adjunct_addition %> | | ||
<%= link_to 'Back', adjunct_additions_path %> |
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,26 @@ | ||
<h1>Listing adjunct_additions</h1> | ||
|
||
<table> | ||
<tr> | ||
<th>Adjunct type</th> | ||
<th>Time</th> | ||
<th>Amount</th> | ||
<th>Secondary</th> | ||
</tr> | ||
|
||
<% @adjunct_additions.each do |adjunct_addition| %> | ||
<tr> | ||
<td><%=h AdjunctType.find(adjunct_addition.adjunct_type_id).name %></td> | ||
<td><%=h adjunct_addition.time %></td> | ||
<td><%=h adjunct_addition.amount %></td> | ||
<td><%=h adjunct_addition.secondary %></td> | ||
<td><%= link_to 'Show', adjunct_addition %></td> | ||
<td><%= link_to 'Edit', edit_adjunct_addition_path(adjunct_addition) %></td> | ||
<td><%= link_to 'Destroy', adjunct_addition, :confirm => 'Are you sure?', :method => :delete %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<br /> | ||
|
||
<%= link_to 'New adjunct_addition', new_adjunct_addition_path %> |
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,27 @@ | ||
<h1>New adjunct_addition</h1> | ||
|
||
<% form_for(@adjunct_addition) do |f| %> | ||
<%= f.error_messages %> | ||
|
||
<p> | ||
<%= f.label :adjunct_type_id %><br /> | ||
<%= f.collection_select(:adjunct_type_id, AdjunctType.all, :id, :name) %> <br /> | ||
</p> | ||
<p> | ||
<%= f.label :time %><br /> | ||
<%= f.text_field :time %> | ||
</p> | ||
<p> | ||
<%= f.label :amount %><br /> | ||
<%= f.text_field :amount %> | ||
</p> | ||
<p> | ||
<%= f.label :secondary %><br /> | ||
<%= f.check_box :secondary %> | ||
</p> | ||
<p> | ||
<%= f.submit 'Create' %> | ||
</p> | ||
<% end %> | ||
<%= link_to 'Back', adjunct_additions_path %> |
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,23 @@ | ||
<p> | ||
<b>Adjunct type:</b> | ||
<%=h AdjunctType.find(@adjunct_addition.adjunct_type_id).name %> | ||
</p> | ||
|
||
<p> | ||
<b>Time:</b> | ||
<%=h @adjunct_addition.time %> | ||
</p> | ||
|
||
<p> | ||
<b>Amount:</b> | ||
<%=h @adjunct_addition.amount %> | ||
</p> | ||
|
||
<p> | ||
<b>Secondary:</b> | ||
<%=h @adjunct_addition.secondary %> | ||
</p> | ||
|
||
|
||
<%= link_to 'Edit', edit_adjunct_addition_path(@adjunct_addition) %> | | ||
<%= link_to 'Back', adjunct_additions_path %> |
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,16 @@ | ||
class CreateAdjunctAdditions < ActiveRecord::Migration | ||
def self.up | ||
create_table :adjunct_additions do |t| | ||
t.integer :adjunct_type_id | ||
t.integer :time | ||
t.float :amount | ||
t.boolean :secondary | ||
|
||
t.timestamps | ||
end | ||
end | ||
|
||
def self.down | ||
drop_table :adjunct_additions | ||
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
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,13 @@ | ||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html | ||
|
||
one: | ||
adjunct_type_id: 1 | ||
time: 1 | ||
amount: 1.5 | ||
secondary: false | ||
|
||
two: | ||
adjunct_type_id: 1 | ||
time: 1 | ||
amount: 1.5 | ||
secondary: false |
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,45 @@ | ||
require 'test_helper' | ||
|
||
class AdjunctAdditionsControllerTest < ActionController::TestCase | ||
test "should get index" do | ||
get :index | ||
assert_response :success | ||
assert_not_nil assigns(:adjunct_additions) | ||
end | ||
|
||
test "should get new" do | ||
get :new | ||
assert_response :success | ||
end | ||
|
||
test "should create adjunct_addition" do | ||
assert_difference('AdjunctAddition.count') do | ||
post :create, :adjunct_addition => { } | ||
end | ||
|
||
assert_redirected_to adjunct_addition_path(assigns(:adjunct_addition)) | ||
end | ||
|
||
test "should show adjunct_addition" do | ||
get :show, :id => adjunct_additions(:one).to_param | ||
assert_response :success | ||
end | ||
|
||
test "should get edit" do | ||
get :edit, :id => adjunct_additions(:one).to_param | ||
assert_response :success | ||
end | ||
|
||
test "should update adjunct_addition" do | ||
put :update, :id => adjunct_additions(:one).to_param, :adjunct_addition => { } | ||
assert_redirected_to adjunct_addition_path(assigns(:adjunct_addition)) | ||
end | ||
|
||
test "should destroy adjunct_addition" do | ||
assert_difference('AdjunctAddition.count', -1) do | ||
delete :destroy, :id => adjunct_additions(:one).to_param | ||
end | ||
|
||
assert_redirected_to adjunct_additions_path | ||
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,8 @@ | ||
require 'test_helper' | ||
|
||
class AdjunctAdditionTest < ActiveSupport::TestCase | ||
# Replace this with your real tests. | ||
test "the truth" do | ||
assert true | ||
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,4 @@ | ||
require 'test_helper' | ||
|
||
class AdjunctAdditionsHelperTest < ActionView::TestCase | ||
end |