Converting Rails 2 app with ActiveMessaging to Rails 3, have a few questions - ruby-on-rails-3

I'm currently converting a fairly large Rails 2 app to Rails 3. The app uses activemessaging in its plugin form. It's used with Amazon SQS primarily for file uploads, among a few other things. I have the all the queues I use defined in messaging.rb and there are existing processors to handle messages. In the Rails 3 version I'm switching over to the activemesssaging gem, version 0.9.0. Aside from getting rid of the old plugin version is there much else I need to do to my existing messaging.rb and processors? Also right now I manually start the poller script, is that the same? I can't seem to find much info about Rails 3 and activemessaging so if anyone can give me the basic steps of what I need to do it would be much appreciated. Thanks.

I don't remember there being a big difference with using the gem - I did not change the way messaging.rb or broker.yml are loaded, and you still have to start the poller yourself.
In general there is not a big difference with Rails 3, which is why you aren't seeing much about it.

Related

Alternate way for Starling/Workling for background process in rails 3.2

Currently we are using starling/workling in our rails application.But we are facing some issues with starling/workling background process.So we are thinking to replace it with some other better process. Could you please let me know alternate background process for rails.
You have several ways of doing that, you can find video tutorials here.

Ruby Rails--easy way to get animated front end?

I am developing a web-based simulation where I want the front-end to be "animated" in real-time--it will be a mapping application, and I want to have little icons (representing the components of my simulation) moving all over the map as the simulation runs. I am developing the back-end in Rails, but I am wondering what are good packages to use for the front-end / animation part? I used Graphviz to generate the base map (a directed graph), but it doesn't seem well suited for live animations.
Something like Hans Rosling's Gapminder (if it's even possible to do in real-time). Or should I be doing something similar and "recording" the data then playing it back? What packages should I consider in that case?
Gapminder
Currently using Rails 3.0, Ruby 1.9.2, Graphviz 2.28.
Here are 2 javascript libraries that may help. You could use ajax calls to your rails backend to populate their data. I'm unsure if D3 has mapping capability, but I believe Raphael does. As far as real-time, you'll have to check out their documenation. In Rails 4, I believe the streaming capability may benefit you as well, but I've not investigated.
Raphael
D3

Can Rails's scheme.rb recreate the scaffolds automatically?

Using schema.rb, I think we can actually convert an older Rails 3.0 project to a Rails 3.2.3 project, rebuilding the database using this schema.rb file.
But if I just used scaffolds to create all the RESTful resources before in the 3.0 project, then won't the scaffolds need to be generated once again for this new Rails 3.2.3 project also? If that is the case, won't it be not useful to use scheme.rb? Because we will create all the migration files along the way anyway and do the rake, and we can just generate the extra create index migrations along the way.
Or is there a better way? Such as a way that the old scaffolds and old database tables and indexes can be recreated automatically? The old database can be used or discarded, so it is a cleaner option to start the sqlite database fresh from the start.
Is there a reason you want to scrap the existing project/database to build a new one? It's usually pretty easy to just update the rails version in your Gemfile, run bundle install, and then just fix anything that breaks (which, if you were using the default scaffolding, won't be much). The existing database will work just fine with either 3.0 or 3.2, as well as all of your old scaffolding files.
You should check out this railscast to see how to go from rails 3.0 to 3.1, so you can see the basics of upgrading. Upgrading from 3.1 to 3.2 is even easier.
To answer your original question, there is no straightforward way to regenerate scaffolds using schema.rb. The scaffolds are only a starting point to help you as you start to build a model/controller, there would usually be no point in recreating them since you usually end up modifying them heavily afterwards anyway.
You can use this "reverse scaffold" script:
https://github.com/ahe/reverse_scaffold
It will generate the required html.erbb file right in your app/views folder.
It pretty well explained on the Readme page.
And, it's updated for Rails 3.2

Is it possible to inject code from script into running rails app

Assume I have a running ruby on rails app.
I’m creating classes (db-models) defined by a description provided at runtime.
Right now, I’m using the rails app (via browser) to trigger the code generation — and therefore the app “knows” about its new classes.
But, is it possible to inject code from scripts executed inside the rails app directory?
Like…
$ [path/to/app] rails s
$ [path/to/app] script/apply_schema
Since RoR supports many helpers for both generating tables, columns etc. I do not see why you want to do this using script injection. this would not only be a very weird way of inputting and rendering data but it would also create quite a security risk.
Then comes my second question (in runtime) how would you define authentication? since you are trying to inject code?
I would advise using the SQL helpers to create/update/destroy attributes. this is based on a much used and effective architecture. also using relations makes you able to build quite alot while still remaining in the "safe" environment RoR offers.
If you want to try a framework wich offers data injection on runtime try Meteor

How can I implement write through caching in Rails 3 similar to cache-money?

I recently inherited a Rails 2.3 application that I'm now trying to upgrade to Rails 3. Cache-money is an integral part of the application so I want to make sure we have the same functionality in place when we go to Rails 3. However, my research on the subject has shown that cache-money is not compatible with Rails 3 (due to the use of unsupported AR methods :find_every and :find_from_ids).
I've seen a couple of comments and blogs mention that implementing the type of write through caching with Rails 3 that cache-money provided should be a trivial task. Any ideas on how to approach implementing write through caching with Rails 3?
Last week I launched a new write-through-cache gem for Rails 3, see
https://github.com/orslumen/record-cache.
The reason I built it, is because we were using cache money in a Rails 2.3 project and recently migrated to Rails 3. So chances are, it will also serve you well.
Writing your own write-though caching in Rails 3 does not sound like a trivial task to me. If you do find a trivial way, please be sure to copy me in on that.