Added generated RESTful RatesController. #1916
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
class RatesController < ApplicationController
|
||||
# GET /rates
|
||||
# GET /rates.xml
|
||||
def index
|
||||
@rates = Rate.find(:all)
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.xml { render :xml => @rates }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /rates/1
|
||||
# GET /rates/1.xml
|
||||
def show
|
||||
@rate = Rate.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.xml { render :xml => @rate }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /rates/new
|
||||
# GET /rates/new.xml
|
||||
def new
|
||||
@rate = Rate.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.xml { render :xml => @rate }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /rates/1/edit
|
||||
def edit
|
||||
@rate = Rate.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /rates
|
||||
# POST /rates.xml
|
||||
def create
|
||||
@rate = Rate.new(params[:rate])
|
||||
|
||||
respond_to do |format|
|
||||
if @rate.save
|
||||
flash[:notice] = 'Rate was successfully created.'
|
||||
format.html { redirect_to(@rate) }
|
||||
format.xml { render :xml => @rate, :status => :created, :location => @rate }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.xml { render :xml => @rate.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /rates/1
|
||||
# PUT /rates/1.xml
|
||||
def update
|
||||
@rate = Rate.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @rate.update_attributes(params[:rate])
|
||||
flash[:notice] = 'Rate was successfully updated.'
|
||||
format.html { redirect_to(@rate) }
|
||||
format.xml { head :ok }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
format.xml { render :xml => @rate.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /rates/1
|
||||
# DELETE /rates/1.xml
|
||||
def destroy
|
||||
@rate = Rate.find(params[:id])
|
||||
@rate.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(rates_url) }
|
||||
format.xml { head :ok }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,28 @@
|
||||
<h1>Editing rate</h1>
|
||||
|
||||
<% form_for(@rate) do |f| %>
|
||||
<%= f.error_messages %>
|
||||
|
||||
<p>
|
||||
<%= f.label :amount %><br />
|
||||
<%= f.text_field :amount %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :user_id %><br />
|
||||
<%= f.text_field :user_id %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :project_id %><br />
|
||||
<%= f.text_field :project_id %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :date_in_effect %><br />
|
||||
<%= f.date_select :date_in_effect %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.submit "Update" %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<%= link_to 'Show', @rate %> |
|
||||
<%= link_to 'Back', rates_path %>
|
||||
@@ -0,0 +1,26 @@
|
||||
<h1>Listing rates</h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Amount</th>
|
||||
<th>User</th>
|
||||
<th>Project</th>
|
||||
<th>Date in effect</th>
|
||||
</tr>
|
||||
|
||||
<% for rate in @rates %>
|
||||
<tr>
|
||||
<td><%=h rate.amount %></td>
|
||||
<td><%=h rate.user_id %></td>
|
||||
<td><%=h rate.project_id %></td>
|
||||
<td><%=h rate.date_in_effect %></td>
|
||||
<td><%= link_to 'Show', rate %></td>
|
||||
<td><%= link_to 'Edit', edit_rate_path(rate) %></td>
|
||||
<td><%= link_to 'Destroy', rate, :confirm => 'Are you sure?', :method => :delete %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
<%= link_to 'New rate', new_rate_path %>
|
||||
@@ -0,0 +1,27 @@
|
||||
<h1>New rate</h1>
|
||||
|
||||
<% form_for(@rate) do |f| %>
|
||||
<%= f.error_messages %>
|
||||
|
||||
<p>
|
||||
<%= f.label :amount %><br />
|
||||
<%= f.text_field :amount %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :user_id %><br />
|
||||
<%= f.text_field :user_id %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :project_id %><br />
|
||||
<%= f.text_field :project_id %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :date_in_effect %><br />
|
||||
<%= f.date_select :date_in_effect %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.submit "Create" %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<%= link_to 'Back', rates_path %>
|
||||
@@ -0,0 +1,23 @@
|
||||
<p>
|
||||
<b>Amount:</b>
|
||||
<%=h @rate.amount %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>User:</b>
|
||||
<%=h @rate.user_id %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Project:</b>
|
||||
<%=h @rate.project_id %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Date in effect:</b>
|
||||
<%=h @rate.date_in_effect %>
|
||||
</p>
|
||||
|
||||
|
||||
<%= link_to 'Edit', edit_rate_path(@rate) %> |
|
||||
<%= link_to 'Back', rates_path %>
|
||||
Reference in New Issue
Block a user