Skip to content
Snippets Groups Projects
Commit 88f91d17 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

After running './script/generate scaffold CallAttempt'

parent 4bc90e02
No related branches found
No related tags found
No related merge requests found
class CallAttemptsController < ApplicationController
def index
list
render :action => 'list'
end
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
verify :method => :post, :only => [ :destroy, :create, :update ],
:redirect_to => { :action => :list }
def list
@call_attempt_pages, @call_attempts = paginate :call_attempts, :per_page => 10
end
def show
@call_attempt = CallAttempt.find(params[:id])
end
def new
@call_attempt = CallAttempt.new
end
def create
@call_attempt = CallAttempt.new(params[:call_attempt])
if @call_attempt.save
flash[:notice] = 'CallAttempt was successfully created.'
redirect_to :action => 'list'
else
render :action => 'new'
end
end
def edit
@call_attempt = CallAttempt.find(params[:id])
end
def update
@call_attempt = CallAttempt.find(params[:id])
if @call_attempt.update_attributes(params[:call_attempt])
flash[:notice] = 'CallAttempt was successfully updated.'
redirect_to :action => 'show', :id => @call_attempt
else
render :action => 'edit'
end
end
def destroy
CallAttempt.find(params[:id]).destroy
redirect_to :action => 'list'
end
end
module CallAttemptsHelper
end
class CallAttempt < ActiveRecord::Base
end
<%= error_messages_for 'call_attempt' %>
<!--[form:call_attempt]-->
<p><label for="call_attempt_cid">Cid</label><br/>
<%= text_field 'call_attempt', 'cid' %></p>
<p><label for="call_attempt_from">From</label><br/>
<%= text_field 'call_attempt', 'from' %></p>
<p><label for="call_attempt_when">When</label><br/>
<%= datetime_select 'call_attempt', 'when' %></p>
<!--[eoform:call_attempt]-->
<h1>Editing call_attempt</h1>
<%= start_form_tag :action => 'update', :id => @call_attempt %>
<%= render :partial => 'form' %>
<%= submit_tag 'Edit' %>
<%= end_form_tag %>
<%= link_to 'Show', :action => 'show', :id => @call_attempt %> |
<%= link_to 'Back', :action => 'list' %>
<h1>Listing call_attempts</h1>
<table>
<tr>
<% for column in CallAttempt.content_columns %>
<th><%= column.human_name %></th>
<% end %>
</tr>
<% for call_attempt in @call_attempts %>
<tr>
<% for column in CallAttempt.content_columns %>
<td><%=h call_attempt.send(column.name) %></td>
<% end %>
<td><%= link_to 'Show', :action => 'show', :id => call_attempt %></td>
<td><%= link_to 'Edit', :action => 'edit', :id => call_attempt %></td>
<td><%= link_to 'Destroy', { :action => 'destroy', :id => call_attempt }, :confirm => 'Are you sure?', :post => true %></td>
</tr>
<% end %>
</table>
<%= link_to 'Previous page', { :page => @call_attempt_pages.current.previous } if @call_attempt_pages.current.previous %>
<%= link_to 'Next page', { :page => @call_attempt_pages.current.next } if @call_attempt_pages.current.next %>
<br />
<%= link_to 'New call_attempt', :action => 'new' %>
<h1>New call_attempt</h1>
<%= start_form_tag :action => 'create' %>
<%= render :partial => 'form' %>
<%= submit_tag "Create" %>
<%= end_form_tag %>
<%= link_to 'Back', :action => 'list' %>
<% for column in CallAttempt.content_columns %>
<p>
<b><%= column.human_name %>:</b> <%=h @call_attempt.send(column.name) %>
</p>
<% end %>
<%= link_to 'Edit', :action => 'edit', :id => @call_attempt %> |
<%= link_to 'Back', :action => 'list' %>
<html>
<head>
<title>CallAttempts: <%= controller.action_name %></title>
<%= stylesheet_link_tag 'scaffold' %>
</head>
<body>
<p style="color: green"><%= flash[:notice] %></p>
<%= @content_for_layout %>
</body>
</html>
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
first:
id: 1
another:
id: 2
require File.dirname(__FILE__) + '/../test_helper'
require 'call_attempts_controller'
# Re-raise errors caught by the controller.
class CallAttemptsController; def rescue_action(e) raise e end; end
class CallAttemptsControllerTest < Test::Unit::TestCase
fixtures :call_attempts
def setup
@controller = CallAttemptsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
def test_index
get :index
assert_response :success
assert_template 'list'
end
def test_list
get :list
assert_response :success
assert_template 'list'
assert_not_nil assigns(:call_attempts)
end
def test_show
get :show, :id => 1
assert_response :success
assert_template 'show'
assert_not_nil assigns(:call_attempt)
assert assigns(:call_attempt).valid?
end
def test_new
get :new
assert_response :success
assert_template 'new'
assert_not_nil assigns(:call_attempt)
end
def test_create
num_call_attempts = CallAttempt.count
post :create, :call_attempt => {}
assert_response :redirect
assert_redirected_to :action => 'list'
assert_equal num_call_attempts + 1, CallAttempt.count
end
def test_edit
get :edit, :id => 1
assert_response :success
assert_template 'edit'
assert_not_nil assigns(:call_attempt)
assert assigns(:call_attempt).valid?
end
def test_update
post :update, :id => 1
assert_response :redirect
assert_redirected_to :action => 'show', :id => 1
end
def test_destroy
assert_not_nil CallAttempt.find(1)
post :destroy, :id => 1
assert_response :redirect
assert_redirected_to :action => 'list'
assert_raise(ActiveRecord::RecordNotFound) {
CallAttempt.find(1)
}
end
end
require File.dirname(__FILE__) + '/../test_helper'
class CallAttemptTest < Test::Unit::TestCase
fixtures :call_attempts
# Replace this with your real tests.
def test_truth
assert true
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment