trying to add this to my rails project https://github.com/adelevie/parse-ruby-client
so i first obviously bundle installed the gem, then i created a parse.rb file in config/initializers with this code :
require 'parse-ruby-client'
client = Parse.create :application_id => 'API_KEY',
:api_key => 'API_KEY',
when i call client anywhere i get a error that its undefined
In your example client is a local variable. By the time you try to access it, it has already left the scope. What you should do is create or use a globally visible object. One example:
require 'parse-ruby-client'
::MyParse = Parse.create :application_id => 'APP_ID',
:api_key => 'API_KEY',
You can access such object as MyParse in the code.
Another example:
require 'parse-ruby-client'
MyApp::Application.configure do
config.parse = Parse.create :application_id => 'APP_ID',
:api_key => 'API_KEY',
end
And use it like this:
MyApp::Application.config.parse
Related
I am working on dashing dashboard and trying to add a Jira widget.In the widget code it is trying to create and initialize a Client object. As shown in code below
require 'Jira'
SCHEDULER.every '5m', :first_in => 0 do |job|
client = Jira::Client.new({
:username => ENV['Talal'],
:password => ENV['Talal123'],
:site => "http://192.168.99.100:32768",
:auth_type => :basic,
:context_path => "/jira"
})
But as I gets to this line client = Jira::Client.new. An exception occurs which states that uninitialized constant Jira::Client.
I believe the gem you should be using is jira-ruby. Once you install it, Bundler should automatically require it for you, meaning if you're in a Rails environment, you shouldn't need to do require 'Jira'.
If you don't want it required application-wide, BTW, you should add this to your Gemfile:
gem 'jira-ruby', require: false
# then in your scheduler, you have to explicitly require it as before:
require 'jira-ruby'
SCHEDULER.every '5m', :first_in => 0 do |job|
client = Jira::Client.new({
:username => ENV['Talal'],
:password => ENV['Talal123'],
:site => "http://192.168.99.100:32768",
:auth_type => :basic,
:context_path => "/jira"
})
Additional information here
I am using the omniauth-magento gem: http://rubydoc.info/gems/omniauth-magento/0.0.6/frames
Setting my omniauth.rb file in initializers as such:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :magento, "TOKEN", "SECRET", :client_options => { :authorize_path => "/su", :site => "https://store.magento.com" }
end
The store needs to be dynamic though. How can I make it such OR how can I do the same thing in a controller?
Thanks!
I should mention there is another gem: https://github.com/Contiamo/omniauth-magento which allows to set dynamically but i have no clue where to put this.
hey i'm trying to access contacts from gmail/yahoo etc using omnicontacts gem,
https://github.com/Diego81/omnicontacts
i'm able to get the responce from the site but not able to rout to my page and getting routing errors
Internal Server Error
uninitialized constant ContactsLists
and
uninitialized constant ContactsListsController
or
The action 'gmail' could not be found for InvitesController
config files are below
Rails.application.middleware.use OmniContacts::Builder do
importer :gmail, "client_id", "client_secret", {:redirect_path => "/contact_callback"}
end
in google console
Redirect URIs is set to
mylocaldomain.com/contact_callback
and i want t oroute the data to my contact_list controller and invite method so in routes i have defined
match "contact_callback" => '/contacts_lists/invitenew'
and i'm getting http://mylocaldomain.com/contact_callback?code=4/jGYoPAYuZiuW5uR2UjDPmqF6Hjtj.4oxoCiD-BVUQXE-sT2ZLcbShVA5nhwI
let me know what i'm doing wrong.
** EDIT **
omnicontacts.rb
#check https://github.com/Diego81/omnicontacts for more info
Rails.application.middleware.use OmniContacts::Builder do
importer :gmail, "XXX", "****", {:redirect_path => "/contact_lists/gmail/contact_callback"}
importer :yahoo, "XXX", "****", {:callback_path => "/conta"215641561956751", "86245e1a6e7ce9b9e59cf440d5262e12",ct_lists/yahoo/contact_callback"}
importer :hotmail, "000000004011440B", "ah89ykZYvM1CcohvJhdcfEKaJL9Oktjt" , {:redirect_path => "/contact_lists/hotmail/contact_callback"}
importer :facebook, "XXX", "****", {:redirect_path => "/contact_lists/facebook/contact_callback"}
end
routes.rb
get "/contact_lists/facebook/contact_callback" => "contact_lists#getfbinvite"
# get "/contact_lists/:provider/contact_callback" => "contact_lists#getinvite" #commented temp
get "/contact_lists/gmail/contact_callback" => "contact_lists#getinvite"
get "/contact_lists/yahoo/contact_callback" => "contact_lists#getinvite"
get "/contact_lists/hotmail/contact_callback" => "contact_lists#getinvite"
This will solve the problem for me.now i have all diff function for all sites as per requirement. Hope this helps you .
I have the following code in my app.
require 'aws-sdk'
require 'rubygems'
AWS.config({
:access_key_id => 'XXXXXXXXXXXXXXXXX',
:secret_access_key => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
ec2 = AWS::EC2.new(:ec2_endpoint => 'ec2.ap-southeast-1.amazonaws.com')
##i = ec2.instances.create(:image_id => 'ami-aabXXXXX', :instance_type => 't1.micro', :security_groups=> ['Drum-Factory'], :key_name => 'some-key' )
sleep 1 while ##i.status == :pending
......
How can i name my instance while creating it, so that it will appear in the Name column of my AWS Management Console.
Name column is actually a tag added to the instance
So you need to set the value of "Name" tag
My guess is something like this
##i.tags["Name"] = "value"
or
tag = ec2.tags.create(##i, "Name","Value")
check http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/EC2/TagCollection.html#create-instance_method
also this SO answer might be of help
For AWS, how do you set tags to a resource with the ruby aws-sdk?
I'm trying to use the twitter_oauth gem : http://github.com/moomerman/twitter_oauth
In my model I have:
require 'twitter_oauth'
And within a function I have:
def example
client = TwitterOAuth::Client.new(
:consumer_key => 'xxxx',
:consumer_secret => 'xxxx',
:token => "xxxx",
:secret => "xxxx")
return client
end
This seems fairly straight forward, but I can't seem to find out why I'm getting this error:
(Event being the name of the model)
uninitialized constant Event::TwitterOAuth
I can't seem to locate any conflicts with the TwitterOAuth namespace, any other thoughts?
Decided to use Grackle instead, seems to work fine