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

  • Home
  • SEARCH
  • 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 8046447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:47:19+00:00 2026-06-05T05:47:19+00:00

I am developing a web application with Ruby on Rails/Jquery Mobile. The SQLite ‘Inventory’

  • 0

I am developing a web application with Ruby on Rails/Jquery Mobile.

The SQLite ‘Inventory’ schema consists of existingfixture:string, replacementfixture:string, and quantity:integer. There are two other tables called oldlights and newlights. These simply contain the options for existingfixtures and replacementfixtures, respectively. Oldlights and newlights both have lightname:string and value:integer, where value is how many Watts the given light name uses.

Here is a screenshot of how it looks

I also want my program to display, the difference in watts from existing to replacement fixture. I want to be able to have another column saying how many Watts are saved anually, but I have no idea how to go about this. The values are associated in oldlights/newlights. However, I can’t figure out how to access them and perform mathematical equations with them in a seperate column.

Code for Displaying values from database:

<fieldset class="ui-grid-c"><center>
         <div class="ui-block-a"><%= inventory.existing %></div>
         <div class="ui-block-b"><%= inventory.replacement %></div>
         <div class="ui-block-c"><%= inventory.quantity %></div>
         <div class="ui-block-d"><%= link_to 'Remove', [inventory.client, inventory], 
               :confirm => 'Are you sure?',
               :method => :delete %></div></center>
</fieldset>

Code for adding inventory

    <%= form_for([@client, @client.inventories.build]) do |f| %>
       <fieldset class="ui-grid-c">
         <div class="ui-block-a"><%= f.select :existing, Olight.all.collect{|p| [p.name]}, { :include_blank => true } %></div>
         <div class="ui-block-b"><%= f.select :replacement, Nlight.all.collect{|p| [p.name]}, { :include_blank => true } %></div>
         <div class="ui-block-c"><%= f.number_field :quantity, "data-mini" => "true" %></div>
         <div class="ui-block-d"></div>
       </fieldset>
       <%= f.submit 'Add Inventory'%>
     <% end %>
  • 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-05T05:47:21+00:00Added an answer on June 5, 2026 at 5:47 am

    Sebastien is partly correct. (Parsing the fixture name won’t work, since in the “1-4′ 40W-T12-ESMB” naming, 40 isn’t the wattage of the fixture, but that of a single 4 foot T-12 lamp, and the engineering isn’t as simple as the wattage of a “3-4′ 40W-T12-ESMB” fixture == 3 times the wattage of a “1-4′ 40W-T12-ESMB” fixture. The aggregate fixture wattage depends on a number of other factors in addition to lamp wattage.)

    You should read a this page! “Section 3 – Making Select Boxes with ease” for more information on how to setup your drop lists — I like to construct using options_for_Select. I believe you want the form where the name is displayed, but the id of the old and new fixtures is what is stored in your database.

    In your rails controller when you are saving an inventory combination (existing, replacement, and count), you use the old and new fixture ids to look up their wattages, do the math, then store the savings value. When the page is displayed, all the data should be present.

    On a style note, I’d move the Olight/Nlight.all.collect code out of the page template and into the controller, setting up instance variables to be used by the view…

    @existing = Olight.all.collect{|old| [old.name, old.id]}
    @replacement = Nlight.all.collect(|new| [new.name, new.id]}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If developing web applications using ASP.NET MVC or Ruby on Rails make the application
I am new to Ruby On Rails & developing a web application with Facebook
I'm developing a web application using ASP .NET MVC 1.0 and jQuery (including the
I'm developing a Ruby web application on top of GAE-Java and development is painfully
I am using Ruby on Rails v3.0.9 and I have a web application running
Im Developing a web application which is very critical. So authentication has to be
I am developing a Web application in Pylons on the Mac. My development server
I am developing a web application. For some reasons, I need to use external
I'm developing a web application for a company which I work for. My team
I am developing an web application using php. One of the requirement is the

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.