Creating a basic facebook application with Rails - ruby-on-rails

I am creating a simple facebook application using Ruby on rails and I am following the liveRail tutorial available here
http://www.liverail.net/articles/2007/6/29/tutorial-on-developing-a-facebook-platform-application-with-ruby-on-rails
The problem that Im facing is that when I launch my server it throws an error saying that it cant find the 'gem_original_require' : no such file to load facebook_rails_controller_extensions.
I have added the rfacebook gem but the error is thrown when i include the require
require "facebook_rails_controller_extensions" in the environment.rb file.
Im not completely sure whether this is the right way to go with Rails 2 but I've between making changes when i find relevant information for Rails 2
I would appreciate any suggestions on this or any links to other tutorials too.
Thank you

That tutorial is SEVERELY out-of-date and you're going to have lots of issues if you keep following it. rFacebook hasn't be actively maintained in a good 2 years. You should be using Facebooker.
There is a good facebooker tutorial here: http://apps.facebook.com/facebooker_tutorial/

Examine your $LOAD_PATH variable.
It's a common issue that your load path doesn't contain library.
Use $LOAD_PATH<<'/usr/lib/superrubylib' to add a path to load.
Uh, and it seems to be a best practice to use require File.dirname(__FILE__) + "/../relative/path" to set up relative paths.
P.S. Please, specify more data about paths and locations to let us answer your question specifically.

Related

Ruby on Rails - In what file do I add the following: require 'forecast_io'?

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

How to convert a large gem to standalone rails app

I'm building a social network and have been using the gem community_engine but have been having trouble implementing the large amount of customization that I need for my app. I figure this will make it easier for me to override and add methods, as well as help me to better understand and learn from the code since I will be able to actually see all of it in action.
So far in my attempt I downloaded the source code, added the default bin directory and config files that were missing, as well ass all the gem dependencies.
What else do I need to do to get the app to work? I realize that there may still be a lot and that it might not be easy to explain, but at the very least is there any sort of documentation out there that might help me understand how to convert the gem to a Rails application?
Heres the community_engine repo: https://github.com/bborn/communityengine
Because this idea may draw some criticism, I'll add that I was originally building the app without any huge plugins accept for devise however I'm running out of time to finish this.
More stuff I've tried:
Moving files to a new rails app, got server to run but encountered many seemingly random errors, fixed a few but more just seem to pop up that I cant figure out:
I also took a look at http://guides.rubyonrails.org/plugins.html but this gem seems to go beyond that.
I would suggest that you clone the gem and begin copying files from the gem into your a new Rails application.
The engine gem probably has a similar structure to a Rails application, so you should be able to move the files from the corresponding folder to the same folder in your Rails root folder.
You may need to move gem files out of modules, change namespaces etc. Relevant folders to look at files you'll want to include might include app/ config/ db/, any gem dependencies in Gemfile or the gemspec file, as well as spec/ or test/.
Beyond that I think there's no silver bullet answer to your question, you're just going to have to work through problems until you have this up and running, and perhaps ask subsequent questions if you hit on an obstacle that you don't get beyond.
I think what you're looking for is a way to hook your Rails Engine into a rails app. The Hooking Into an Application section of the Getting Started with Rails Engines guide should be exactly what you're looking for.
Here are two additional resources on Rails Engines.
A Guide to Rails Engines in the Wild
Rails::Engine - Ruby on Rails API

Setting up ruby on rails gem ga_events

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.

Can multiple Rails Applications share models/common business domain data between them?

I have several use cases that manipulate and add to the same data at different points in the process.
Each of these use cases share many of the same models, and actions in the process but would require totally different views and structure.
I was thinking of trying out the tips in this article from 8thLight but this was written in 2007.
http://blog.8thlight.com/jim-suchy/2007/02/20/sharing-a-database-among-multiple-rails-applications.html
According to them, the trick is to
(1) make a new folder with the shared models right above the application.
applications_in_same_business_domain
|-shared_models
|-application1
|-application2
|-...
(2) require this new folder or module in your application via enviorments.rb file
(which I believe the equivalent would be config/application.rb because I don't see enviornments.rb in Rails 3.)
They say some code like this will work (in environments.rb)
$: << File.dirname(__FILE__) + '/your_lib_path'
I tried this and it isn't working (in application.rb)...
config.autoload_paths += %W(../../../mardom_shared_models)
Is this the standard way to do this?
An API sounds like another way to do this...but...I don't know anything about API's here. Self-learning 6-Month Noob here)
Helping me get the above to work if it is possible I guess would be the specific question. Can I do this?
But any comments or articles on other matter would be appreciated.
I would need to modify the Rails generators here starting from this link: http://guides.rubyonrails.org/generators.html
I would rather put all models related stuff into a gem, and install gem locally to vengor/gems directory to simplify navigating in it.

Rails SequencedHash source file

I am testing AlumniOnRails (http://rubyforge.org/frs/?group_id=2959&release_id=17170) which is based on Rails 1.2.6 (I know it's outdated) and managed to get it up, installed the required gems, created and migrated the data and most of the basic alumni functionalities are up but one, the part that is broken seems to be missing a library and yet I can't seem to find it after a few reasonable searches.
The logger shows no such file to load -- collections/sequenced_hash with a line within the controller having the code of require 'collections/sequenced_hash which is quite obvious that the sequence_hash library is missing.
A few searches on Google shows a few references, one with the closest pointer is http://collections.rubyforge.org/classes/SequencedHash.html but unfortuntely the source link is dead. Does anyone keep this kind of old file or point me to somewhere it is? Thank you
Somebody answered this over ruby forum and it works:
gem install collections

Resources