Added OS view, minor issue resolved.

Added view (data pull thru 2 tables so a little more trickier than colors and resolutions, so used the loop to build an IN statement in the SQL for the id's based on which ones were found in the first find. 🙂
Initially found that only some data was only getting returned but then realized that loop.osrcid should be loop.osid to pull the id from the referenced detail table, not (it's) 2nd referenced table.

# operating systems - *** looping and making sure to allow MULTIPLE ANDS for OS versions *** by os_source!
# so we're checking for os_source... but adding operating_system (osrcid)... and that is as intended.
    @the_operating_systems_by_os_source = ''  # to prevent errors
    @the_db_operating_systems = OperatingSystem.find_by_sql("select as osid, as osrcid, Concat(OSRC.source,' ',OS.operating_system_name) as os_name_source, OSRC.source from operating_systems OS join os_sources OSRC on OS.os_source_id = order by os_name_source")
    if (params[:os_source])
      @the_operating_systems_by_os_source = ' AND operating_system_id IN (-1'
      @the_db_operating_systems.each do |loop|
        if loop.source.upcase == (params[:os_source].upcase)
          @the_operating_systems_by_os_source+= ',' + loop.osid  # see above comment for use of osrcid
      @the_operating_systems_by_os_source+= ')'

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s