[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

RoR Find using Conditions, or find_by_sql?

Posted on 2008-10-15
1
Medium Priority
?
1,243 Views
Last Modified: 2013-11-13
Hi, im trying to query my database and am passing a type variable with value "Hardware", a manufacturer variable with value of "Dell and an invoice variable with value of "SI11244"

Here is the url im putting into my browser:
http://localhost:3000/assets/findbyparams?manufacturer=Dell&type=Hardware&invoice=SI11244

i have a findbyparams method in my controller but have no idea how to put these values into a find statement to return the aassets where the TYPE column equals "Hardware, the MANUFACTURER column equals "Dell" and INVOICE column equals "SI11244"

thanks
0
Comment
Question by:Jonesey007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 14

Accepted Solution

by:
wesgarrison earned 2000 total points
ID: 22727750

def find
  @type = params[:type]
  @manuf = params[:manufacturer]
  @invoice = params[:invoice]
  
  @assets = Asset.find_all_by_type_and_manufacturer_and_invoice(@type, @manuf, @invoice)
  @assets = Asset.find(:all, :conditions => ["type = ? and manufacturer = 
? and invoice = ?", @type, @manuf, @invoice])
end
 
# both should return the same thing

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Ruby, Call or invoke a API DLL library is easily via Win32API class, win32-api gem or other gems. For general DLL API call, there are quite a few references, some good tips list below: http://www.rubytips.org/2008/05/13/accessing-windows-api-fro…
Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question