When i tried to migrate my project from rails 3.0.6 to rails 3.2.rc2.
I found a lot of changes.one change seems to be node.js as javascript runtime.
whats the advantages on having node.js on it.By having node.js.
is it possible to migrate the rails lower version to the latest one
Rails 3.1 (and later) uses javascript runtime to compile CoffeeScript assets to javascript. You don't have to have node.js, there are other supported javascript runtimes.
Related
I'm guessing that since newly scaffolded Rails apps use webpacker, adding a gem like react rails would be an anti-pattern. that said, is there a canonical way to enable ssr on a rails app with react or would I need to run node as well for this?
I recently went through trying the 3 popular solutions:
Rails + Webpacker
Rails + Webpacker + react_on_rails
Rails + Webpacker + react-rails
react_on_rails opinion... It doesn't use integration tests that can use RSpec (Capybara) to combine both React + Rails environments. Both webpack and rails server are running via the foreman gem, which means you'd have to add another complex configuration to have RSpec integration tests that traverse both. There is also way too many settings that I was already configuring myself (Docker, Heroku, to name a couple...). The commit history the past year is also mostly doc changes (looking now this past couple weeks there has been some activity, though). Also it promotes a "Pro" edition, which kinda turned me off tbh.
react-rails is much more light-weight and was just easier to get working. The team is the official React team (reactjs.org). It "just worked" for me.
If you need a starting point, I'd recommend checking out this Rails starter kit that is built as a Rails + React setup:
https://github.com/patrickclery/dry-rails-react
Particularly these files:
babel.config.js
app/javascript/packs/application.js
app/javascript/packs/server_rendering.js
package.json
config/webpacker.yml
The gems are just another option, wondering why you see this gem in rails as an anti-pattern as there is a section in the react-rails gem documentation specific to webpacker. It clearly describes how to use the react-rails gem with Webpacker.
Here's another pretty up-to-date resource, which provides examples for
Webpacker
react-rails
react_on_rails
For webpacker it says:
All files in the new app/javascript/packs directory are compiled by Webpack.
For react-rails it says:
react-rails is the official React community gem for integrating React with Rails. The main benefit of using this gem is the react_component helper method which makes it easy to pass Rails data to components.
react-rails also gives you the option to continue using the default Rails asset pipeline to serve your React code, instead of using webpacker
For the third option react_on_rails it says:
The other most popular third-party gem for integrating React into Rails is the react_on_rails gem created by ShakaCode.
Similar to the react-rails gem, now that Rails already provides an easy way to use React via webpacker, you have to see if the stated benefits of the react_on_rails gem apply to your situation.
I currently have a gem installed on my development machine. Now that I want to use this gem on the production but I could not install it due to some issue with the server. Is there a way that I can convert this gem to a plugin so that I can transfer it to the server?
if no, is there a way to transfer this gem from my machine to the server?
BTW, I'm using an old version of Ruby on Rails (2.1)
Thanks.
Just copy the gem's single source code file into your project's lib directory. https://github.com/ambethia/smtp-tls/blob/master/lib/smtp-tls.rb
Well, if the plugin is compatible with Rails 2.1 you should be able to move the plugin to your /vendor directory, and it should work from there. As mentioned in the comments, the vendor directory is going to be removed and that style of plugins will be removed in Rails 4, but for Rails 2.1 that doesn't matter.
To get the files, go on rubygems.org and find the project homepage. You can probably find the source code for the plugin you're interested in (including a version that's compatible with Rails 2.x) on Github, then just clone it to your vendor directory.
What do I need to modify to change my ordinary Ruby on Rails project into a JRuby on Rails project? In addition, is it likely that a gem I included in my RoR project will be broken in the JRuby version of my project?
Lastly is there any way to create a JRuby on Rails app in APTANA or any other editor?
You will need to switch to Jruby instead of Ruby and this could be done using RVM. (www.beginrescueend.com)
You will have problems with gem compatibility when you switch to jruby not all gems will work. Usually gems with C extensions.
Lastly, for an IDE I am sure aptana is fine. You are still writing ruby code. Just when you run your code you will be using the JVM.
The main advantage of jruby instead of normal ruby is we can call the java libraries. And if you want you can even use Hibernate.
And switching if you are on a windows machine you need to use PIK(RVM for windows).
Like ericraio said there may be some gem dependency but most of the time the bundler will take care of that, so you don't need to worry about things(Most of the time).
If you want to check a particular gem please visit this site http://rubygems.org/
For my development I'm using NetBeans 6.9.1. If you want any help regarding how to make you first program in netbeans I'm ready to help.
I prefer to use command prompt to create and run rails project
This may be a very lame question, but still I am confused when should I use a gem and when should I should use a plugin in my project.
What's the basic difference between them?
The basic difference is a gem is something that needs to be installed on the system running your Rails application, whereas a plugin is deployed along with your application. More specifically, plugins live in vendor/plugins whereas gems need to be install using rake gem install gem_name.
As for when to use each, gems tend to be easier to keep up to date, but more specifically, some gems use native C code and are compiled specifically for a given operating system (such as Nokogiri). These need to be installed as gems as they will not work when moved to another system. Whereas some things like acts_as_commentable use straight ruby code and can be moved from system to system.
From RailsGuides:
A Rails plugin is either an extension or a modification of the core framework.
From Rubygems.org:
A gem is a packaged Ruby application or library.
So, the biggest difference between the 2 is that Rails plugins are specifically made for use within Ruby on Rails applications, whereas gems aren't.
For example, let's look at Geokit.
The gem (geokit-gem) provides the fundamental location-based operations.
The Rails plugin (geokit-rails) mixes location finders into ActiveRecord.
Here you can see that the gem provides the core of Geokit. This gem can be used anywhere, not just a Rails app. The plugin provides additional features for those who are using geokit within a Rails app. In this case, using the plugin as well as the gem is optional.
When you install a plugin in a project it can be used only in the respective project. But if u install a gem, it can be used by every project. This is the main difference of Gem & Plugins.
Gems are distributed by rubygems, which is the official ruby library package manager. Plugins is a (probably hacky) way for rails plugins. I recommend you using gems whenever possible, due to dependency resolution. Rails3 ecurages that by packing with Bundler.
I use gems whenever a gem works as I wanted to and plugins when I want to do a custom change for a specific rails application and not affect all of my system.
If so, how?
When you go to http://rubyonrails.org/download, it says:
We recommend Ruby 1.8.7 for use with
Rails. Ruby 1.8.6, 1.8.5, 1.8.4 and
1.8.2 are still usable too, but version 1.8.3 is not.
Rails does work in 1.9 as of 2.3. I suppose they still recommend Ruby 1.8.7 because it has the most compatibility with other Ruby libraries — a lot of them are still catching up.
From the announcement of Rails 2.2:
Jeremy Kemper has been rocking on both Ruby 1.9 and JRuby compatibility. Rails 2.2 is fully compatible with both, but again, there might be supporting libraries and gems that are not. Again, lots of work is going into making everything else fully compatible as well.
Then, from the release notes for Rails 2.3:
Rails 2.3 should pass all of its own tests whether you are running on Ruby 1.8 or the now-released Ruby 1.9.1. You should be aware, though, that moving to 1.9.1 entails checking all of the data adapters, plugins, and other code that you depend on for Ruby 1.9.1 compatibility, as well as Rails core.
Based on their discussion board, Rails 2.3.0RC1 and later versions are compatible with Ruby 1.9.1 (and presumably, any later 1.9 versions). I'm guessing they haven't gotten aroudn to updating the site properly.
Rspec has only recently been ported to 1.9, therefore many gems have not been able to run their test suites in 1.9 until recently, so many gems are not yet stable in 1.9