Rails 3: Using a gem as my main app - ruby-on-rails

I want to use the code of a gem as my main application code instead of just installing it with "bundle install".
How can I create an entire rails app based on a gem and using that gem as my app?
Thank you.

You are looking for Rails Engines instead I believe. If not, then can you explain your problem further?

Related

Ruby on Rails Vacuum Gem

I am new to Ruby on Rails and I am trying to access the Amazon Product API using the Vacuum Gem. Based off this code https://gist.github.com/frankie-loves-jesus/89d24dd88579c7f912f3 I am getting an error at the first line
request = Vacuum.new('GB')
telling me that I have an "Uninitialized constant AmazonAPIController::Vacuum" every example on this gem tells me to use this line of code but I can't understand how to fix the error. It seems to be as simple as putting the code into my controller and showing it.
You didn't add the gem to your Gemfile I guess and didn't run bundle install afterwards. Also you should make sure to restart your Rails server after every change in your Gemfile.
If all that doesn't help, you also could try to just gem install vacuum and then require 'vacuum' in the file you are using (but I would recommend getting it to work on another way).

How to install ember activemodel-adapter

I'm using ember-rails with ember-source and ember-data-source. But somehow the activemodel-adapter is not included in either of the gems. Or I'm missing something. I also searched bower, and can't find any. The code seems to be at: https://github.com/emberjs/data/tree/master/packages/activemodel-adapter
But it also needs compile. I'm wondering if there is an easier way to use it.
You must explicitly load a recent version of Ember Data. For example, add a version to the ember-data-source gem in your Gemfile:
gem 'ember-data-source', '~> 1.0.0.beta.7'
The active model adapter is included with Ember Data. Assuming everything in your project is global you could use it for your entire application like so:
App.ApplicationAdapter = DS.ActiveModelAdapter;

How to manange projects that doesn't have gem file?

Under Rails 2 projects doesn't have the gemfile.
In this case which is the best way to manage the gems?, which gems should I vendor? also I will like to know if there's another way to manage this?
You can manage gem using bundle in rails 2.3 app ,you can refer
http://gembundler.com/rails23.html
http://yehudakatz.com/2009/11/03/using-the-new-gem-bundler-today/

Suitable gem for auditing

I want to trace my rails application such as who created the data,who made the changes with that and what is its old and new value. Let me know which gem is suitable for that.I'm using paper_trail but not able to see the changes.
Try Audit_log gem. And check here and here also for better understanding
You can use Audit Rails gem too for this.

How to develop Gems?

I would like to write my own gem that helps me in my rails apps. It will also inculde some controllers that deliver html. So i need to test that in a browser (html/css/js).
Whats the best practice for that?
Now im using the echoe gem to build my gem (are there any better gems?).
rake install
switch to other tab
stop the rails app
start the rails app (so it has loaded the gem)
and then testing it, in a browser with good old refresh.
This is no fun. Can i do it more efficient somehow? Is it insane not to write tests for the ruby files?
You could use two resources to help you:
https://github.com/krschacht/rails_3_engine_demo
https://github.com/josevalim/enginex
This will help you creating a gem which will basically be an engine (enabling controller and views). The first link as great and helpful documentation.
The main principle is to code in a separate folder and add your 'gem' in local by doing gem ‘cheese’, :path => "../rails_3_engine_demo"
Once you feel ready, pack it with jeweller or bundler. Here is another link: http://sirupsen.com/create-your-first-ruby-gem-and-release-it-to-gemcutter//
Including the gem this way in your app will enable you to properly test it's behaviour.
jeweler:Opinionated tool for creating and managing Rubygem projects

Resources