Reputation: 183
I have an URL :
Example.com/searchjobs/jobs/sales
So, I just want to pass 'sales' keyword to my @query
variable in my controller, but it remains nil.
I tried several tutorials but they only show how to use friendly_id with a model.
Thanks for your help.
searchjobs_controller.rb
class SearchjobsController < ApplicationController
def jobs
require 'nokogiri'
require 'open-uri'
@query = params[:qw]
@xmls = Nokogiri::XML(open(URI.escape("http://api.indeed.com/ads/apisearch?publisher=apikey&q=#{@query}&l=&sort=date&radius=&st=&jt=&start=&limit=50&fromage=&filter=&co=uk&userip=#{@ip}&useragent=#{@useragent}&v=2")))
end
end
Model searchjob.rb
class Searchjob < ActiveRecord::Base
extend FriendlyId
friendly_id :qw
end
end
Routes.rb
match '*qw', to: 'searchjobs#jobs', via: :get
Upvotes: 0
Views: 235
Reputation: 4015
Try to change your route to this:
match '/searchjobs/jobs/:qw', to: 'searchjobs#jobs', via: :get
Upvotes: 1