Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8102407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:14:06+00:00 2026-06-05T23:14:06+00:00

I have an application where I have a Shipment model. I have created a

  • 0

I have an application where I have a Shipment model. I have created a view that allows me to create shipments and view shipments in a table based layout. Everything lies in the index.html.erb because all actions are done through ajax.

When a shipment is created, the status is “OPEN” by default. Later on when a bill of lading is printed, the status will change to “PRINTED”.

My goal is to create another view that lists only the open shipments allowing an operator to print the bill of lading using a separate form. My question is how does rails handle the rendering of multiple forms and views for one model? Should I use a separate controller/view to handle the action/views associated with printing, or should I use two models for ex. Shipment and OpenShipment? I’m having a hard time finding documentation that explains this issue.

Listed below is my schema for this Model as well as a directory structure for the current view. Hope this helps explain the issue.

Shipment Model
  t.string    :item_code
  t.string    :status
  t.string    :bill_of_lading
  t.integer   :qty_shipped
  t.datetime  :ship_date
  t.datetime  :delivery_date

View Directory Structure

views
   shipments
      index.html.erb
      _shipment.html.erb
      _shipment_table.html.erb
      _form.html.erb
      _edit_form.html.erb
      create.js.coffee
      edit.js.coffee
      update.js.coffee
      destroy.js.coffee     
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:14:07+00:00Added an answer on June 5, 2026 at 11:14 pm

    As I see, you will be showing the same thing twice. You could solve this in two ways: either you add a parameter, and keep the same controller action, or you add a new controller action (which possibly makes a cleaner url –depends on your preference).

    First, you define a scope on Shipment:

    class Shipment
    
      scope :open, lambda { where(:status => 'open')
    
    end
    

    This will allow to write something like:

    Shipment.open
    

    and this will give you all the open shipments.

    So you could define a new controller action as follows

    def open_shipments
      @shipments = Shipment.open
      render :index
    end
    

    This will retrieve the open shipments, and then render the same view as for index.

    To make it even cleaner, you could make the state a parameter in your url.
    In your config/routes.rb write

    get 'shipments/status/:status', :as => 'shipments#index'
    

    And then you will have to edit your index action as follows:

    def index
      if params[:status]
        @shipments = Shipment.where(:status => params[:status])
      else
        @shipments = Shipment.all
      end
    end
    

    And you can then just visit the url shipments/status/open which will give the open shipments, and likewise shipments/status/printed will give all the printed shipments.

    But the url shipments?status=open will give you the same result (without any changes to the routes necessary). Depends on your flavour.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have application with following design: Table View that lists documents. And ViewController where
I have application that generates a lot of numbers and writes them to table
I have application that makes different queries with different results so the caching in
I have application that is connecting to the DB and if I enter incorrect
I have application that is up more than 3 days. I can see in
I have application 1 and application 2. App2 needs to verify that App1 is
I have application that brings response via Ajax and creates 5-20 new jQuery click
I have application created with Spring and has access through jmx to set some
We have application that runs 24h per day and 7 days per week. Sometimes
I have application that uses IPv4 addresses (it stores them as long), so it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.