Determine which Rails version I'm using when using Railties - ruby-on-rails-3

Stupid question:
I'm using Railties version 3.2.3 and wish to check which version of Rails its running exactly (what with the recent number of security issues). I've looked into the gem's code but can't seem to get a handle on it. Perhaps I'm being stupid and the rails version matches that of realties?
Either way I'd appreciate help on this.

Rails::VERSION::STRING returns the currently running version of Rails when used within your app.

Related

Setup neo4j and Rails 3.2 with Ruby MRI

I want to try using neo4j with Rails 3.2 app which is using Ruby MRI.
In this setup doc, bundling the app requires ActiveSupport 4, so, the question is whether it's possible to use the current setup (ActiveSupport 3.2.x) without using JRuby.
The preferred setup is to use server db, not embedded.
Thanks
That is a good question. I took a look through the git logs and I can't tell when it was switched from version 3 to version 4. It looks like it has been using 4 since version 3.0.0 of the neo4j gem, though, which is when we started supporting server mode.
With regards to JRuby, even if it was an option for you, you would still need to use ActiveSupport so I don't think it would help.
I tried changing activesupport, activemodel, and railties to version 3 in the gem and running the specs and came up with this:
/Users/brian/github/neo4jrb/neo4j/lib/neo4j/active_node/scope.rb:1:in `require': cannot load such file -- active_support/per_thread_registry (LoadError)
from /Users/brian/github/neo4jrb/neo4j/lib/neo4j/active_node/scope.rb:1:in `<top (required)>'
from /Users/brian/github/neo4jrb/neo4j/lib/neo4j.rb:89:in `require'
So it looks like there's at least one thing in ActiveSupport 4 that we depend on.
If this is really important, I would suggest forking the neo4j repository and including it in your Gemfile like this:
gem 'neo4j', github: 'your_username/neo4j'
Then in your repository you can change the neo4j.gemspec to use version 3 of the gems that I listed above. Then you'd need to fix the issue I mentioned above and any others that you might run across. Obviously this would make it difficult to keep up with the latest changes to the gem.
Generally I'm in favor of supporting older versions of Rails / ActiveSupport as much as we can. It looks like the upgrade to ActiveSupport 4 preceded me, but we'll definitely thinking thrice before depending on any features in 5.
Good luck!

Hard time installing Ruby on Rails because of different RVM versions

I'm following Michael Hartl's Ruby on Rails tutorial book and am trying to install rails. As the book says, I followed the instructions on InstallRails.com and got through most of it until I was told to run rails server and I kept getting the error that I didn't have railties gem not installed. I had initially ran sudo gem install rails and so I read that it didn't pick up railties for some reason but gem install rails did - so that fixed it. So now I was able to run rails server and the app was live.
I returned to the book and as the instructions say, I generated a new rails app, specifying the rails version (4.2.2). However, when I run rails again, I get errors. At this point, having tried a dozen different stackover flow solutions, I feel like I must have screwed up the files and maybe I should just get rid of rails completely and try installing from scratch.
Here's some information on where I'm currently at:
Faiques-MacBook-Pro:Desktop Faique$ rails -v
Rails 4.2.3
Faiques-MacBook-Pro:Desktop Faique$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
Faiques-MacBook-Pro:Desktop Faique$ mkdir workspace
Faiques-MacBook-Pro:Desktop Faique$ cd workspace
Faiques-MacBook-Pro:workspace Faique$ rails _4.2.2_ new hello_app/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'railties' (= 4.2.2) - did find: [railties-4.2.3] (Gem::LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/ ubygems/dependency.rb:307:in `to_spec'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /usr/bin/rails:22:in `<main>'
I'm not sure what other information I should provide.
This isn't an ideal solution but what I ended up doing was completely restoring my mac and then reinstalling rails but using rbenv instead as per a friend's recommendation. I am now set up with Rails.
I wanted to do a complete restore (deleting all my data) because I had tried so many stack overflow answers for different errors - including using sudo for certain commands - that I'm sure I had messed some important settings and would take a long time to figure out. I think this was surprisingly one of the more efficient solution, although far from ideal.

New Relic ActiveRecord::ConnectionNotEstablised Rails 3.2.3 error

I just installed the newrelic_rpm gem in my RefineryCMS Rails 3.2.3 application. I copied in the newrelic.yml config file as per the instructions. My app is being deployed with Heroku on the Cedar stack, so the instructions were pretty simple.
https://devcenter.heroku.com/articles/newrelic#cedar
However, running "rails server" on my development box gave me this error message:
/home/xxx/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in `retrieve_connection': ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)
Setting the agent_enabled value to "false" in the newrelic.yml file allowed the server to start up again. Setting my license key and app name environment variables made no difference.
Interestingly, even though I couldn't get the app to start on my dev box, when I deployed it to Heroku, everything worked fine - and I am now getting new relic stats. Great!
My workaround has been to remove newrelic_rpm from the gemfile (which is what the install instructions say to do), and put it only into a :production group. Obviously, new relic is only useful in production, so it's no big deal.
group :production do
... other gems
gem 'newrelic_rpm'
end
Anyone else ever experienced this, or know why it should be causing an ActiveRecord error (with no mention in the error trace of new relic at all)?
The issue you were running into looks like a bug in the newrelic_rpm gem that was addressed with our (I work at New Relic) recent 3.6.4 release. I'd suggest that you try updating to 3.6.4 to see if the issue persists.
By way of explanation: we have something in the newrelic_rpm gem called an EnvironmentReport, which gathers information about the environment your application is executing in (Rails version, gem versions, DB adapter, Ruby version, etc) to display in the UI. In version 3.6.0 of the newrelic_rpm gem, we pushed the generation of the EnvironmentReport into a background thread. Because the EnvironmentReport potentially referenced the ActiveRecord::Base constant, generating it could trigger some ActiveRecord initialization code paths that are not thread-safe. If the EnvironmentReport happened to hit ActiveRecord::Base at just the wrong time, it could trigger errors like what you were seeing on the main thread.
We addressed this in 3.6.4 by moving the generation of the EnvironmentReport back onto the main thread.
Sorry for the headache, and please let us know if 3.6.4 doesn't solve your issue.
Edit - hmm, just noticed that you asked about this before 3.6.0 was released. I'd still suggest trying 3.6.4, since I suspect a similar race condition may have existed in older versions of the newrelic_rpm.

Gem for sorting and searching

I am using rails version 3.2.6. I have to use the gem for sorting and searching for the index pages in my application. I know about jquery-datatables-rails gem. I just want to know if there is some other gem for sorting and searching that is supported in rails 3.2.6. I had also searched for datagrid gem but did not get the proper ducumentation for that and if it(datagrid) is supported in rails 3.2.6.
Active Scaffold (https://github.com/activescaffold/active_scaffold) is probably over top, or? Its my most-used-gem. Of course it has sorting and searching build in, configurable and fast. Check it out, following the getting started guide in the wiki you should have an app up and running in 10 minutes.

Is there a simple way to tell if a Gem will work in Rails3?

I wanted to use this gem:
https://github.com/PRX/apn_on_rails
Finally, after digging through the issues, seems it's not Rails3 ready (yet). Is there some simple way of finding is something is Rails 3 compatible without digging all over?
Thanks!
Aside from creating a fresh Rails app and giving it a try, I tend to look at the commit messages of forks created by other users (i.e. https://github.com/PRX/apn_on_rails/network). In this instance, it looks like there is a fork that runs on Rails 3 that is still being maintained.
Generally, if it isn't mentioned in the readme (on github) then no. Most gems I have used explicitly specify rails 2 and rails 3 install instructions. If this is not the case, then usually someone else will have asked this question and a quick search will reveal.
One other giveaway is the install instructions. The rails 2 way of installing a gem via a Gemfile is:
config.gem GEMNAME
The rails 3 way is:
gem 'apn_on_rails'
This answer is related to the gem you are looking for.