ruby - Rails: Calculating the sum of several results based on different field types -


My users have many inputs related to them. What do I need to do? All The amount of: Contribution (a column on the investment model) is being calculated (I'll get it below).

In my Administrator , I have:

  # investment type which is Roth IRA, traditional IRAS etc. @getighter = Investment usually I Just add the .sum (: contribution) to that query. (User ID: Current_User, Investment Type: ["Roth IRA", "Traditional IRA", "Other"])  

However, not all contributions are made equal.

Investment has a contribution area, which is a string where users select "monthly", "quarterly", or "yearly"

Added Controller :

investment = getira.find (params [: contribution frequency]) #IRA contribution frequency evaluation if invest.contributionfrequency == "quarter" @ Contribution_quarterly = (Investment.contribution.to_i * 4) / 12 Elsef Conflicts Conflict == "Monthly" @contribution_memsty = InvestmentContributions.it_IELL InvestmentContributionsFrankness == "Annual" @contribution_anial = Investment Contribution. TiI * 12 End

When I do this, I get this error:

No investment can be found without id

I'm not sure if the right query, or if I'm not passing in the right areas here.

You should get an error No investment can be found without id

  investment = @ getira.find (params [: contributionfrequency])  

This means that is params [: contributionfrequency] Zero that is, you have not passed the key : frequency of contribution in the parameter .

According to the chat session with OP, parameter [: contribution] was deleted and a direct query was used:

  @contribution_quarterly = Investment ("Contribution") (Contribution :) @contribution_monthly = Investment Where (user_id: current_user, type of investment: ["Roth IRA", "investment"): [user_id: current_user, url, url, url, ("contribution") (contribution: contribution) @contribution_annually = "Roth IRA", "Traditional ER", "Other"], Frequency of Subscription: ["Monthly"]., "Traditional IRA", "Other"], Contribution: ["Annual"]). Yoga (: Contribution)  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -