Rails 3.2 + Require.js? - ruby-on-rails-3

I've been reading a lot of info on Require.js. AMD seems very interesting and I got it to work in a standalone backbone.js app. However, Sprocket in Rails seems to conflict with it. Do you recommend projects to go with standard Rails asset pipeline without Require.js?
I saw this article but it's for Rails 3.1, so not sure if it's still applicable: Using RequireJS with a Rails 3.1 app
Also, Underscore no longer seems to be supporting AMD. I don't want to use yet another package to work with Backbone.

I did this awhile ago I used the "use" requireJS plugin to load incompatible libs like underscore.js
https://github.com/tbranyen/use.js
and I think I only included require.js into the sprockets assets, and used it like in any other application.

Related

Does Radiant support Rails 3 now?

I use gem install radiant to install radiant, and I found that it doesn't support Rails 3. But, I found there is a file named "GemfileRails3" in the source code of Radiant on Github, I wonder why is that. Does Radiant really not support Rails3?
Radiant still does not support Rails 3 at this moment. A lot of work towards that has been done, but the project is lacking momentum, making it hard to say when this can be released.

Libraries classes in Ruby on rails

I'm going to develop an application on Ruby on Rails which has many library classes. But I have no such idea. Is it possible or not in Rails? If possible, how can I develop my own library class in rails application? Please suggest me.
since i do not understand your question very well, i can only guess what you mean.
there are several ways of abstracting logic in ruby and ruby on rails.
the most general approach is creating ruby gems. this is a package of ruby code that can be used in every ruby project. it's possible to hook into rails through gems via railties.
there are two things that are specific to rails. the first one are plugins, that work very similar to gems and are considered a legacy way of providing functionality, but there are still some plugins around, especially for rails apps prior version 3.
the other thing is engines. these are micro-applications that can be mounted into any rails app. they are self-contained and can provide a lot of functionality based on their namespaced routes.
since rails is based on rack, it's also possible to hook any rack-conform ruby application into the rails router. through this approach it's possible to connect rails apps with ie. sinatra applications.

Migrating from Rails 2.3 to 3.2 over a long period

I'm working on a small project that has been allocated a small amount of time to maintain and update features. This project is on Rails 2.3.
I'd like to move it to Rails 3.2 but there is little time allocated to this so I would like to do it over a slow gradual process.
I'm thinking that it might be worth moving over to Rails 3.2 on a section-by-section basis.
This would mean that I would create a second application that looks the same as the first one but is located somewhere different and accessed from a different subdomain.
Is this feasible if I just update the Rails 2.3 routes file for certain routes to go to the new application?
Has anyone done this before?
It depends on many parameters but among these the most relevant are :
Does your Rails 2 project already use Bundler ? If not, migrate to it before the migration.
Do you use gems which are known not to work on Rails 3 ?
Does your project already use Rails XSS plugin (https://github.com/rails/rails_xss) ? If not, migrate to it before the migration.
After that, the migration will be easier.
For the migration, I recommend that you create a brand new Rails application using "rails new" command, so that all the boot files will be good. Then migrate the initializers/config files and "app" folder...
Good luck.

Upgrade Rails 2.3.14 to Rails 3.1.0, or re-write app fresh in Rails 3.1.0

I have upgraded my app to Rails 3.1.0, and while I have solved many compatibility issues, but I have also noticed that there are many redundant files, junk codes, and some features I have to recode again.
I am just wondering if I should just rewrite my app from fresh in Rails 3.1.0, or continue modifying and fixing after the upgrade? The former one will produce a cleaner app, but more work, and the latter one will be faster, but will also take some time to clean up the mess. What is my best approach?
Thanks.
what I do is create a fresh empty rails 3.1 app. Install my gems with bundler. Then I copy over my migrations, my models and my spec tests. Run my tests. Get tests passing, resolve any incompatibility issues. Repeat with config/routes, controllers, views, etc.

Rails 3.1 Engines Modules

When creating a mountable Rails 3.1 engine using
rails plugin new my_engine --mountable
it creates the engine at MyEngine::Engine < Rails::Engine
Is there a way to generate it like the jQuery::Rails engine (Jquery::Rails::Engine), or do I have to do it manually?
I tried these, and of course it didn't work.
rails plugin new "my_module/my_engine" --mountable
rails plugin new "my_module::my_engine" --mountable
I took a peek in the rails source, and you won't like the answer. Plugin generation seems to make the assumption that your engine name isn't nested, like here.
If you really insist on not doing this by hand, you could try to hack your way through the generator or use a PluginBuilder with the -b option of the rails plugin new command. It doesn't look documented though, a quick search on Google didn't reveal any info, but I may have overlooked something.
Hope this helps.