Ruby/Rails Command to get details on the app enviorment - ruby-on-rails

I am working on a web application running on Rails 2.1 version.
I would like to know if there is any single command in rails or ruby that could fetch me in the console, all the details about my application like the version of my back end DB, Rails, Ruby and all relevant information pertaining to my web app.
This would help me to get all necessary details of my application without having to explicitly
look into each of the details one by one.

I think you can try the ruby script/about command for your rails app. This must work for the Rails 2.1 version.
Running this in the console would give you major environment details about your web application. Something similar to this :
Go to the app directory and run the command
$ ruby script/about
About your application's environment
Ruby version 1.8.7 (i486-linux)
RubyGems version 1.8.11
Rails version 2.1.2
Active Record version 2.1.2
Action Pack version 2.1.2
Active Resource version 2.1.2
Action Mailer version 2.1.2
Active Support version 2.1.2
Edge Rails revision e0a2f6c625d99d68df432a3c3418f4217bd56cbf
Application root /home/path/app_folder #path of your app directory
Environment production
Database adapter mysql
Database schema version 20101110130106

Related

Rails appears as not installed even though it is installed

I'm new to rails. After finally getting my environment to work properly with RVM 2.0.0 rails 4.0.5, all of a sudden rails disappeared and I keep getting the message: Rails is not currently installed on this system...
When I quit terminal, reopen it, and type:
$ rails v
It shows 4.0.5
However, as soon as I change directory into my rails app and check the rails version I get the message that rails is not installed.
Any idea what's going here?
When you use rvm you have multiple versions of ruby installed. You select which one you want like this:
rvm use 2.0
or
rvm use 2.1
You can also specify a ruby version in a .ruby-version file in a directory. Then when you change to that directory in the terminal, RVM will switch versions for you.
Each version of ruby has its own set of installed gems. Rails is a gem.
Ergo, when you installed rails, you were in your default ruby version (probably the one build-in on your system). When you change directory to your rails application, RVM is kicking in to switch to the correct ruby version for you. But you don't have rails installed in that version.
So the solution is to switch to the directory for your rails app and run:
bundle install
This will install your gem bundle for your application, including the rails gems, and it will do it into the correct ruby version.

Rails 3.2 hangs with JRuby 1.6.6

I've been trying to get my Rails application to work TorqueBox and one of its requirements is to use JRuby as the Ruby language variant. I've installed JRuby 1.6.6 and the gemfile seems to bundle itself properly, but when the rails server is booted up and accessed within a browser (at localhost:3000 or 0.0.0.0:3000) then the webpage hangs...
I'm not sure if this is a problem with Rails 3.2 and the rails server does start fine (doesn't show any errors within the console) and the Rails 3.2 instance does work with Ruby 1.9.2. So I think it may be something with my gem file list or perhaps something within an initializer.
Any ideas if this is a common problem?
--- EDIT ---
I'm trying to access 0.0.0.0:3000 from WebBrick.
As far as I know torquebox 2.0 beta 3 is currently tested with jruby 1.6.5.1. Maybe try switching to that jruby version. Also make sure you're running ruby in 1.9 mode. To do that, create a torquebox.yml file in your rails config folder and put the below in it:
ruby:
version: 1.9

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.

Ruby on Rails 3 Tutorial: Chapter 2 Section 2.2.1 A User Tour

I am new to Ruby on Rails and am working through this tutorial book. I am on Windows Vista and using Cygwin. Here are the versions of the software that I am running:
Ruby version 1.9.2 (i386-cygwin)
RubyGems version 1.8.10
Rack version 1.3
Rails version 3.1.0
JavaScript Runtime JScript
Active Record version 3.1.0
Action Pack version 3.1.0
Active Resource version 3.1.0
Action Mailer version 3.1.0
Active Support version 3.1.0
In the beginning of section 2.2, I was able to successfully run: ($ rails generate scaffold User name:string email:string) and ($ rake db:migrate). But when I went to run the ($ rails server) command and opened up the webpage in Chrome, I did not see the screen shown in Fig. 2.4. But instead saw this instead: "Encoding::InvalidByteSequenceError in Users#index" I saw the post about switching the rake version from 0.9.2 to 0.8.7 and I tried this, but it didn't work for me. Does anybody now of anything else that I can try? Thank you, Nick.
I've tried rails learning with Windows 7 + Cygwin and it was a real pain in the ass. I strongly recommend you to run linux on the virtual machine or make a dual-boot.
Since you are using ruby 1.9.2 you can try to add # coding: utf-8 at the beginning of Controller file

Ruby on Rails tutorial - generate question

First attempt at a RoR project and following http://guides.rubyonrails.org/getting_started.html#creating-the-blog-application .
I've got the "Welcome Aboard" page serving.
Within the section 4.2 Say "Hello", Rails the tutorial says to issue the command :
$rails generate controller home index
... and that that will create a file
app/views/home/index.html.erb
... well as far as I can see it doesn't. In fact in the app/views directory there is no sub-directory called 'home' but instead one called 'layout' (which is empty)
When I issue a find command for index the file the file index.html.erb appears nowhere in the tree.
Can anyone provide me with advice on how to make that index.html.erb file (preferably in a manner compatiable with the tut !).
My environment is based on bitnami over ubuntu and looks like this :
Ruby version 1.8.7 (i686-linux)
RubyGems version 1.3.6
Rack version 1.0
Rails version 2.3.5
Active Record version 2.3.5
Active Resource version 2.3.5
Action Mailer version 2.3.5
Active Support version 2.3.5
Application root /home/bitnami/src/rubytest0/my_test_app
Environment development
Database adapter sqlite3
Database schema version 0
If you're using rails pre-3.0 try...
script/generate (instead of rails generate) in the root directory of your Rails project.
Older versions of rails don't allow 'rails generate', so you essentially created a new rails app called generate. As you continue to follow the tutorial, replace any instance of rails command with script/command if you are having trouble.
The tutorial you are referring to explicitly states:
"This Guide is based on Rails 3.0. Some of the code shown here will not work in earlier versions of Rails."
It looks like you are using rails 2.3.5

Resources