I am creating rails API app for managing Trello related boards and lists.
I have decided to use "ruby-trello" gem.
There is a config example at github ruby-trello page (https://github.com/jeremytregunna/ruby-trello).
Config looks like this:
Trello.configure do |config|
config.developer_public_key = 'my_trello_key'
config.member_token = 'my_trello_token'
end
I got key and token from trello devs.
I have added this code to my config/application.rb in class Application.
But when I am trying to get something data from Trello I see this error:
Trello::ConfigurationError (Trello has not been configured to make authorized requests.)
Can anybody help? Where I need to place this config code?
Sorry for my English.
The Rails convention is to put that in config/initializers/trello.rb so that it's picked up when Rails boots.
It's odd they don't seem to mention that in the documentation.
Related
Thanks for your help,
I believe this is very simple but I can't figure it out. Following the instructions at https://github.com/darkskyapp/forecast-ruby - it tells me to not forget to add require 'forecast_io' - what file do I put this in?
I've run a scaffold to set up a simple lat and lng, following this guide:
https://campushippo.com/lessons/an-easy-way-to-implement-weather-forecasting-in-rails-9d10403 but keep on getting method errors. So I think we are using different versions of Ruby & Rails, and/or I'm placing this code in the wrong file, or wrong place. My question isn't about method errors, but just where to place this.
I'm unsure whether or not to place it in /config/application.rb; create and place the code in /config/forecast_io.rb; or to create and place it in /config/initializers/forecast_io.rb; or if it's supposed to go somewhere else entirely.
I've looked at the api docs, the ruby wrapper read me, and also have read other tutorials (they won't let me post more links, otherwise I would list them) - one is from hackpsu.westarate that is kind of different with using sinatra, went through the Treehouse tutorial on Rails scaffolding, and began their tutorial on creating an API to better understand REST, and have looked at other rails projects to see how they incorporate external API's, so I'm in the thick of it, and am banging my head against the wall because it seems so simple, but I'm not seeing it yet.
Thanks for your help!
David
In Rails, placing a gem in your Gemfile already requires the gem by default, unless explicitly stated to ignore.
If you're still bothered about it though, you could add the require option to your gem as such:
gem 'forecast_io', require: 'forecast_io'
Now, for the rest of the configurations mentioned, you can create a file in your initializers and the following:
#config/initializers/forecast_io.rb
ForecastIO.configure do |configuration|
configuration.api_key = 'this-is-your-api-key'
end
Completely lost.
I'm following this sample app tutorial https://www.wepay.com/developer/resources/wefarm-tutorial
which seems like a simple tutorial to follow except I'm building it inside a rails engine. I'm currently attempting to follow the tutorial and initialize the new object.
initialize a new WePay object. add these variables to config/development.rb:
wefarm / config / environments / development.rb
App specific information
CLIENT_ID = 32636
CLIENT_SECRET = "180c800c62"
USE_STAGE = true
WEPAY = WePay.new(CLIENT_ID, CLIENT_SECRET, USE_STAGE)
The issue I think I'm having is the gem is within my core engine allong with user's and the rest of the application and I'm adding these lines of code into the empty shell app. How would I make sure my engine uses this in development I'm also assuming I will come across this issue again when I'm set for production.
In another question a user specified I'm putting this code into the wrong area if I'm using an engine it should be in the initializer folder, but within the documents they just specify putting the code within the config/environments file so where/how exactly do I translate this over to an engine. If it goes into the initializer folder how would I make that file to just include the code specified?
Any help would be amazingly helpful.
Ps. The client Id and secret our just test information
In Rails 4 engine, define the app specific information in secrets.yml
Specifying secrete keys and ids according to environment will solve environment related configuration for keys.
Example :
development:
CLIENT_ID: 123
Make engine configurable
Example in config/initializer/wefarm.rb
Weform.CLIENT_ID = Rails.application.secrets.CLIENT_ID
In lib/engine.rb (engine)
mattr_accessor :CLIENT_ID
Now you can access client_id in engine as WeForm.CLIENT_ID
For more information Rails Engine
We're facing a problem with Stripe API keys. What I've done so far is:
set environment/*.rb to utilise appropriate Stripe keys using constants
created a config/initializers/stripe.rb with the line Stripe.api_key = STRIPE_SECRET
using the rails console, both STRIPE_PUBLIC and STRIPE_SECRET constants are set and visible. STRIPE_PUBLIC => "pk_test_xxxxxxxxx"
However, once these things are in place, making a call to Stripe's API using the browser results in:
Stripe::AuthenticationError in some_controller#some_action
No API key provided. Set your API key using "Stripe.api_key = <API-KEY>". You can generate API keys from the Stripe web interface. See https://stripe.com/api for details, or email support#stripe.com if you have any questions.
Using the web-console gem, we can tell that STRIPE_SECRET and STRIPE_PUBLIC are nil in the website. But every time we run rails console we get our keys from our constants.
I fixed my issue. The terminal running rails server had been opened since before the environment variables had been set.
Therefore, running source ~/.bashrc (for me) or using a new terminal worked for me.
Thank you, sincerely, to everyone who tried to help!
I think the issue you are encountering is happening because if the way you are setting the key.
You cannot expect something you set using the rails console to be available to the web application. The Rails console started up as its own unique process that does not share anything with the web process started and accessed by the browser.
If you want the key to be available to the web application try setting it as an environment variable and reading it accordingly in your stripe.rb file
Try restarting the rails server to make these values available to the rails app since the changes were made in the initializers directory.
I am relatively new to web dev and I am trying to set up the ruby on rails gem ga_events (https://github.com/Nix-wie-weg/ga_events). I am doing this because I need to have google analytics event tracking within controllers and this gem seems like a good way to do it. The issue I am having is where the readme says, "After requiring ga_events.js, you have to choose an adapter." I am using Google Universal Analytics and thus I would like to choose that one. It doesn't say specifically how to do this. Where do I put that code block (https://github.com/Nix-wie-weg/ga_events#google-universal-analytics-analyticsjs)? Do I need to make a new file somewhere?
I'm assuming it's obvious for a more experienced developer. More detailed instructions+explanation would be really helpful. Thanks.
I'm using Rails 4.0.13 and Ruby 2.0.0p643.
I was having the same issue here! Turns out, it is just javascript code.
I put mine under application.js since it's a code that need to be on every page.
I'm trying to get a basic example app running that processes email. Nothing fancy, just the barest of functionality at this point. I've installed Fetcher, configured the YAML, updated the :receiver, and created an IncomingMailHandler class.
When I go to start the FetcherDaemon, I get the following error.
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:105:in `const_missing': uninitialized constant MailerDaemonFetcherDaemon::IncomingMailHandler (NameError)
I'm using Rails 2.3.2, with the latest Fetcher plugin. The IncomingMailHandler class in my models dir looks like this:
class IncomingMailHandler < ActionMailer::Base
def receive(email)
logger.info("Got a mail about: #{mail.subject}")
end
end
Help!
Ok, so basically, I'm a dumbass. I was following instructions all over the damn web, except for the mostly cut and dry explanation on github. Days later now, I just went through the motions, and boom, it worked flawlessly.
So, to anyone that finds this with the same problem (whether you were trying to follow the WAY outdated instructions on the PeepCode tutorial, or found some tips on a blog), don't be a dumbass like me. The most up-to-date info is on github.
Thanks to anyone that looked at this!
My guess is you didnt set the MailFetcher
MailFetcher.mailer_class = :incoming_mail_handler
put this in environment.rb after the RailsInitializer block.
If you want to use POP3 instead of IMAP you have to specify this there as well