mccabec123's Profile User Rating: -----

Reputation: 18 Tradesman
Group:
Active Members
Active Posts:
226 (0.18 per day)
Joined:
03-March 11
Profile Views:
4,048
Last Active:
User is offline Feb 21 2014 06:10 AM
Currently:
Offline

Previous Fields

Country:
GB
OS Preference:
Mac
Favorite Browser:
FireFox
Favorite Processor:
Intel
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
0

Latest Visitors

Icon   mccabec123 has not set their status

Posts I've Made

  1. In Topic: Compiling Array Dynamically Rails/Ruby

    Posted 17 Feb 2014

    Oh sorry, didn't realise you requested that. Here's a sample output for a game 'Tekken'. This is one of the products, but there is a lot more than one
    obviously.

    { "brand" : "ShootFighter Tekken",
      "cat_id" : "11124",
      "category" : "Action",
      "created_at" : 1357812719,
      "genre" : "fighting-action-game-genre",
      "geo" : [ "usa" ],
      "images_total" : 0,
      "manufacturer" : "CENTRAL PARK MEDIA",
      "name" : "ShootFighter Tekken - Complete Collection",
      "offers_total" : 5,
      "platform" : "playstation 3",
      "price" : "19.98",
      "price_currency" : "USD",
      "sem3_help" : "To view image links and additional merchants for this product, please upgrade your plan.",
      "sem3_id" : "1r7BOnBDee882mq2UAyCaK",
      "updated_at" : 1392035685,
      "weight" : "453592.37"
    }
    
    
    

    I need to use the platform element to build the categories and then store all this data within the categories in a product list within the categories for display in the view.

    I was thinking about map myself, but I wasn't quite sure how to apply it, since I haven't had much experience with it. And as for struct I didn't even know you could do this in Ruby, haha, thanks for showing me this. I've used structs in C, but never in Ruby.

    Thanks.
  2. In Topic: Compiling Array Dynamically Rails/Ruby

    Posted 16 Feb 2014

    I don't see how it's a silly structure? I'm looking to create a structure to store the data then pass to the view and print based on categories. It's much better than looping through all the categories and checking each and every record.

    If you can suggest a better alternative, then by all means enlighten me, I'm all ears :)
  3. In Topic: RoR Semantics3 Help Required

    Posted 16 Feb 2014

    Got it all working now, it was just listing the fact that it had a result, I then needed to fetch the results details and store it in an ivar. The final code looks like so after all the changes, just pasting the code here in case anybody else has trouble with semantics:

    class MainController < ApplicationController
    
    	def index
    	end
    
    	def live_search
    		sem3 = Semantics3::Products.new(API_KEY,API_SECRET)
    		if params[:q].present? && sem3.present? # Don't use unless in a branch
    			sem3.products_field( "brand", params[:q] )
    			@records = sem3.get_products()
    			@sem3 = Semantics3::Products.new(API_KEY, API_SECRET) # It helps if you put it in an ivar that's rendered by the action/
    			render :layout => false
    		else
    			@records = { name: "No results found..." }
    		end
    	end
    
    end
    
    
  4. In Topic: RoR Semantics3 Help Required

    Posted 16 Feb 2014

    View PostLemur, on 15 February 2014 - 11:48 PM, said:

    class MainController < ApplicationController
      # require 'semantics3' # Not necessary, include in your gemfile
    
      # Your Semantics3 API Credentials (Which you should put in a config.yml)
      API_KEY = 'CENSORED'
      API_SECRET = 'CENSORED'
    
      # Set up a client to talk to the Semantics3 API
      
    
      def index
      end
    
      def live_search
        if params[:q].present? # Don't use unless in a branch
          @records = sem3.products_field( "brand", "Toshiba" )
          @sem3 = Semantics3::Products.new(API_KEY,API_SECRET) # It helps if you put it in an ivar that's rendered by the action/
          render :layout => false
        else
          @records = { name: "No results found..." }
        end
      end
    end
    
    


    This should work now, assuming you're rendering the correct action.
    <%= @sem3.inspect %>
    
    


    I'm still getting the exact same error unfortunately.

    I'm using Rails 4, do I need some sort of accessor or something within the controller, it seems like it should totally work using this code, but for some reason the sem3 var just doesn't seem to be present when it's getting used in the live_search method. It's really strange. I'm also using Ruby 2.1.0

    Hope this helps :) Thanks for the help so far.

    Okay, so I moved this line:

    sem3 = Semantics3::Products.new(API_KEY,API_SECRET)
    


    down into the live_search method and it seems to work now, however, when I inspect the records ivar it simply prints '1..1' surely it should contain json with the records details no?
  5. In Topic: Best/which Books?

    Posted 11 Feb 2014

    How can you forget Why's Poignant Guide to Ruby?

    Why's Poignant Guide to Ruby

    It's free and funny :P Makes for a good read even if you don't intend on learning Ruby. But it goes through almost everything a Rubyist will need.

My Information

Member Title:
D.I.C Head
Age:
23 years old
Birthday:
July 19, 1991
Gender:
Location:
Scotland
Full Name:
Conner Stephen
Years Programming:
6
Programming Languages:
PHP, C, JavaScript, C++, MySQL, BASH Scripting, Databases, Programming Theory, Ruby, RoR

Contact Information

E-mail:
Private

Friends

Comments

mccabec123 has no profile comments yet. Why not say hello?