Rails 3 - How to install awesome_nested_set - ruby-on-rails

I want to install awesome_nested_set in my Rails 3 app. This is a plugin, versus a gem. I've installed gems but never a plugin.
The awesome_nested_set is here: https://github.com/collectiveidea/awesome_nested_set
But that appears to not be Rails 3 friendly, according to several reported issues.
There is a Rails 3 friendly fork here: https://github.com/FreakyDazio/awesome_nested_set
But I'm not sure how to install this? How do I install this plugin in my Rails 3 app?
Thanks

In Rails 3, install a plugin via:
rails plugin install <path to plugin>
So, for this plugin:
rails plugin install git://github.com/FreakyDazio/awesome_nested_set.git
Using just rails plugin will give you additional information.

In Rails 3, the script/foo scripts have been replaced by calling rails directly, so in your case, to install the FreakyDazio fork of awesome_nested_set:
rails plugin install git://github.com/FreakyDazio/awesome_nested_set.git
Rails by default looks in vendor/plugins (which is where rails plugin install will install to) for plugins to load (at which time, the plugin's init.rb file will be run). Here is an article about plugins in Rails 3. You might want to read about the Rails initialization process as well.

Related

can't create plugin with Rails 3.2?

i've a problem with rails in latest version.
I 've create a new app (rails new MyProject) but i don't have script/generate, only have script/rails and when i type
ruby ./script/rails generate plugin my_plugin
"Could not find generator plugin.".
Do you have any idea how generate plugin template?
it's possible to create plugin without this command?
PS: i'm using Rails 3.2.1 with ruby 1.8.7 [universal-darwin11.0]
The plugin generator has been removed with the release of Rails 3.2.0. See the changelog here. Now you can use the following command:
rails plugin new my_plugin
But be careful because you should run the command outside of the project. It creates a whole plugin structure with its own Gemfile. So, after created the plugin, you can use it in your Rails app adding it to the Gemfile with the path option. Something like:
gem 'my_plugin', path: '/path/to/my_plugin'
I just read that you're using Ruby 1.8.7. Please consider to upgrade to Ruby 1.9.3. Rails 3.2 is the last version of the framework that supports Ruby 1.8.7.

Can I run a Rails 2 and a Rails 3 applications on the same server?

I'm trying to figure out if I can run on the same server(I have an AWS running with ubuntu) a Rails 2 and a Rails 3 applications?
Is this possible? Or I'm just dreaming?
Thanks people.
Yes, it's possible. Ruby and RubyGems are designed to install and run different version of the same Gem on the same server and Rails it's nothing more than a Gem.
My suggestion is to use Bundler to isolate Gem dependencies and Rails versions. It's quite easy to do, Rails 3 uses Bundler by default. You can use Bunder with Rails 2.3 as well. The instructions are on the Bundler website.
When you deploy your project, Bundler will install the necessary dependencies and you'll be able to run two or more projects with several different versions of Rails on the same machine.
Yes it is possible. You need a Ruby Version Manager: https://rvm.io/

rails 3 and acts-as-readable

Does the acts-as-readable plugin work for rails 3? The instructions at https://github.com/mbleigh/acts-as-readable results in Plugin not found: ["http://svn.intridea.com/svn/public/acts_as_readable"]
Downloading the source from github and sticking it in vendor/plugin doesn't seem to work, I get: Could not find generator acts_as_readable_migration.
I am doing something wrong or should I look elsewhere?
I forked the plugin to my GitHub account and updated its generators to work with Rails 3, which can be found at https://github.com/tjackiw/acts-as-readable.
After you install it
rails plugin install git://github.com/tjackiw/acts-as-readable.git
then you can do
rails generate acts_as_readable_migration
Have fun!
try script/rails plugin install git://github.com/mbleigh/acts-as-readable.git to install it from that git repo.
Looks like it will install, but uncertain if it "works" given it hasn't been updated since 2008

Confused about how to install Rails plugins

I found an example here showing how to install a Rails plugin. Their example shows this:
./script/plugin install calendar_helper
This won't work for me because, confusingly, I don't have anything called plugin in my script directory. All I have is rails:
$ ls script/
rails
So Rails doesn't come with the script you need to install plugins? You need a plugin to install plugins? That doesn't seem very likely. Is something wrong with my Rails project?
You're probably on Rails 3. Replace ./script/plugin with rails plugin.
rails plugin install calendar_helper
But the other problem is plugins, unlike gems, need to be installed with a full path. This was also true in Rails 2.x.
rails plugin install https://github.com/topfunky/calendar_helper.git
You should first input text like gem 'calendar_helper' in your Gemfile, and then run bundle install for rails 3.0

In Ruby on Rails, what's the difference between installing something as a gem or as a plugin?

On http://github.com/collectiveidea/delayed_job
it says:
To install as a gem, add the following to config/environment.rb:
config.gem 'delayed_job'
Run rake gems:install
versus
To install as a plugin:
script/plugin install git://github.com/collectiveidea/delayed_job.git
What is the difference between installing it as a gem or as a plugin?
Also, the first method just install gem 2.0.3 which might be the tobi's version? (rake gems:install installs the version by gem list -r delayed_job) Is it http://github.com/tobi/delayed_job ?
The "plugin" method specifically says it is the collectiveidea version? Doesn't it matter which one you install?
Both the Gem and the vendored plugin refers to the collectiveidea's fork. In fact, collectiveidea is the current maintainer for the delayed_job Gem on RubyGems.
That said, generally speaking installing a plugins as a Gem has many advantages.
You can install it once and use it in many different projects
You can take advantage of dependency resolution
You can upgrade just changing version number
You don't need to store the entire plugin code in your SCM
So, why you can install a plugin "as a plugin"?
There are many different answers.
At the very beginning, Rails plugins came as simple libraries. Time passes and developers started to notice the advantage of packaging plugins as Gem.
Also, before Rails 3, some plugin features were only reserved to plugins and not to Gems. For instance, before Rails 3, plugins could bundle rake tasks while there wasn't a way to inject new rake tasks or new routes into the main application.
In the last two years, the most part of Rails plugins offers the ability to be installed as a plugin or as a Gem. With Rails 3 and the arrival of Bundler, I'm sure plugins are going to be deprecated in favor of Gems.
That are 2 different repositorys,
maybe you shoult try
config.gem 'delayed_job', :source => http://github.com/collectiveidea/delayed_job.git
Look at: http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies
Btw. maybe you want to look at a maybe better solution: resque - see http://ruby-toolbox.com/categories/queueing.html for a comparison of used queing gems
When you install a gem it will be available for all apps, in case you use a plugin - just for an app it's installed into.
The basic difference is a gem is something that gets installed on the system running your Rails application, whereas a plugin is installed along with your application, plugin does not get installed on the system level.
suppose you are using rvm and let us take this example.
we have two applications app1 and app2
both are running on a common rvm gemset named gemset1
when you add a gem in the gemfile of app1 and run bundle install and then being in the same rvm gemset which is gemset1, if you run the second app app2 the gem will be available in the second application as well
Whereas with the plugin it will not be the case because plugins get installed on application level and not at the system level

Resources