I am trying to build an app using opentok.I am following a tutorial.in tutorial he used a method and called through before_filer.
private
def config_opentok
if #opentok.nil?
#opentok = OpenTok::OpenTokSDK.new YOUR_API_KEY, YOUR_SECRET_TOKEN
end
end
when i run the same code it shows..
uninitialized constant GroupsController::Opentok
how to initialize opentok instance variable.i changed YOUR_API_KEY and YOUR_SECRET_TOKEN to my own key and token.and i entered api_key without quotes and secret_token with quotes.
thanks in advance.
You should have the following line in your controller
require "opentok"
And use OpenTok::OpenTok instead of OpenTok::OpenTokSDK
Source
Related
My opsworks deployment's node doesnt have [:deploy] object
This is my Chef script
if node[:deploy] === nil
Chef::Log.info("No deployment..")
node[:deploy].each do |app, deploy|
Chef::Log.info("deploy -#{ app }-")
end
elsif
# never goes here
end
i got this error on line 4
undefined method `each' for nil:NilClass (NoMethodError)
firstly, i will advise you to read What does the “===” operator do in Ruby?.
i have a feeling that you meant to use ==, rather than ===. change your triple equal operator to double equal operator and give it a try...
you can use #nil? if you want to make it more readable (depending on your ruby version). change
if node[:deploy] === nil
to
node[:deploy].nil?
I am trying to integrate the Pipl API into my ruby on rails application. I am using ruby version 2.3.4 and rails 4.2.5. As a reference i looked at
this site
and copied the ruby version of the code directly from it into a ruby file. When I run the ruby file in the terminal i get the error:
`<main>': uninitialized constant Pipl::Person (NameError)
Any ideas why I'm getting this error? Any help is greatly appreciated.
This is the code snippet that I used:
require 'pipl'
person = Pipl::Person.new
person.add_field Pipl::Name.new(first: 'Clark', last: 'Kent')
person.add_field Pipl::Address.new(country: 'US', state: 'KS', city:
'Smallville')
person.add_field Pipl::Address.new(country: 'US', state: 'KS', city:
'Metropolis')
response = Pipl::client.search person: person, api_key: 'myKEY' #I used my actual key here
puts "#{response}"
Thanks!
In order to use the Pipl API without the error, I got my API key through their site and I added piplapis-ruby gem just like what was told in the comments above. I imported all of the ruby classes found here: https://github.com/piplcom/piplapis-ruby into my project and pasted the codesnippet.rb file found here: https://github.com/piplcom/piplapis-ruby which was the ruby file you're supposed to execute. There was no need for me to create the Person class.
I am able to launch new instance at AWS from Ruby on Rails application (Chef::Knife::Ec2ServerCreate.new()). Works fine till I try to set JSON attributes. When I set them from command line and invoke knife.bat, it works.
Looking at ec2_server_create shows that command line option --json-attributes is mapped to symbol :json_attributes. I tried to set it using following code:
Chef::Config[:knife][:json_attributes] = "{'NodeName' : 'Node001'}"
and I get error:TypeError (no implicit conversion of Symbol into Integer):
As soon as I comment this single line, instance is created, registered with chef server and recipe is running.
Any suggestion how to set json attributes of first chef-client run?
PS
Sample code shows constant value for attribute, but actual value would be dynamically created.
Error message and code line where error occurs:
/chef/knife/core/bootstrap_context.rb:188:in `[]=': no implicit conversion of Symbol into Integer (TypeError)
Looking into source you can find:
def first_boot
(#config[:first_boot_attributes] || {}).tap do |attributes|
if #config[:policy_name] && #config[:policy_group]
attributes[:policy_name] = #config[:policy_name]
attributes[:policy_group] = #config[:policy_group]
else
attributes[:run_list] = #run_list #THIS LINE CAUSES EXCEPTION
end
attributes.merge!(:tags => #config[:tags]) if #config[:tags] && !#config[:tags].empty?
end
end
I set run list.
The issue is that json_attributes needs to be a hash, not a string. It isn't the #run_list that is failing, it is "{'NodeName' : 'Node001'}"[:run_list] which when you see in on place is probably a bit clearer.
I really don't know where to start with this one, but I am (first time) using Net::IMAP and I am getting the following error:
NameError in EmailsController#connect
uninitialized constant Net::IMAP
Extracted source (around line #4):
2
3 def connect
4 imap = Net::IMAP.new('outlook.office365.com')
5 imap.authenticate('LOGIN', '**#**.com', '**')
6 imap.examine('INBOX')
7 #emails = imap.search(["RECENT"])
Not really sure what is going on here, I don't have to have anything in my Gemfile.rb? Or anything else before I set the imap variable?
You need to require 'net/imap' at the top of the file to bring Net::IMAP into scope.
I tried to install RSRuby following the steps mentioned in http://web.kuicr.kyoto-u.ac.jp/~alexg/rsruby/manual.pdf and http://nsaunders.wordpress.com/2009/05/20/baby-steps-with-rsruby-in-rails/ and I must say that nsaunders blog is indeed a great start for anyone installing RSRuby. But when I tried to check from the irb by creating an instance of RSRuby:
r = RSRuby.instance
it returned me error:
1.8.7-p371 :001 > r = RSRuby.instance
NameError: uninitialized constant RSRuby
from (irb):1
I have all the prerequisites: R_HOME, shared lib option and other stuff. I dont know why I got this error. Any ideas guyzz?????
has anyone tried it for rails successfully???
Without seeing the full source code it's difficult to give you an answer, so this is just a guess. Did you remember to require 'rsruby' within your code? NameError is often caused when a gem is installed but the code does not include the appropriate require statement:
require 'rsruby'
r = RSRuby.instance
You can see this in the code example in the "Documentation" section of the README in the GitHub project.