Marnen Laibow-Koser wrote in post #957913:
> To me too -- if we're talking *files*. But again: that should never
> happen. Let's see your views and controllers. I suspect you are trying
> to cram too much into a single controller, and ending up with lots of
> actions and views as a result.
>
I mis-wrote. As you picked up I really meant view directories. But, why
should it never happen for view directories?
I am writing an application that handles international freight bookings,
movements and customs formalities including edi cusdec transmissions.
That is never ever going to fit into a handful of controllers. In fact,
but for foreign exchange, most controllers possess only the basic index,
show, new, create, and destroy actions. Many do not have all of these.
A sample controller, one of the more complex ones, is given below:
class CustomsShipmentParsChecksController < ApplicationController
skip_before_filter :authenticated
skip_before_filter :authorised
# POST /collection
# POST /collection.xml
def create
respond_to do |format|
if @manifest = CaCustomsManifest.find_by_ccdn(
params[:ca_customs_manifest][:ccdn].strip)
@shipment = @manifest.ca_customs_shipment
@entry = @shipment.ca_customs_entry
if
@manifest.ca_customs_shipment.ca_customs_entry.is_across_accepted
flash[:info] = accepted_message
# render simply uses the template specified by the :action key
# without calling the method.
format.html { render :action => "show" }
format.xml { render :xml => @shipment,
:status => :accepted,
:location =>
:customs_shipment_pars_check }
else
flash[:notice] = not_accepted_message
format.html { render :action => "show", :id => @shipment.id }
format.xml { render :xml => @manifest,
:status => :found,
:location =>
:customs_shipment_pars_check }
end
else
new # build a dummy record complex to allow display of messages
manifest.ccdn = params[:ca_customs_manifest][:ccdn].strip
flash[:notice] = not_found_message
flash[:warn] = contact_message
format.html { render :action => "new" }
format.xml { render :xml => @manifest.errors,
:status => :not_found }
end
end
end
# DELETE /collection/:id
# DELETE /collection/:id.xml
def delete
show
end
# Do not raise pointless not found errors
# GET /collection/:id/edit
def edit
show
end
# GET /collection/new
# GET /collection/new.xml
def new
@shipment = CaCustomsShipment.new
@entry = @shipment.build_ca_customs_entry
@manifest = @shipment.ca_customs_manifests.build
end
# GET /collection
# GET /collection.xml
def index
new
end
# GET /collection/:id
# GET /collection/:id.xml
def show
get_shipment
end
private
...
end
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.