Getting specific Rails version of a Rails 2.x app - ruby-on-rails

Can figure out a Rails app being built on Rails 2.x , as it has a script/server file.
But How do I find which specific Rails version, the app is written in.
doc/README_FOR_APP for this app, does not seem to contain anything helpful in this regard. Any other way I can figure the specific Rails Version for the app.

Try using script/about at the command line.

It is defined in your config/environment.rb. Just run
./script/runner 'puts RAILS_GEM_VERSION'

Related

Rails Tutorial for Beginners

I'm using cloud9 IDE and following the rails tutorial for beginners.
Why doesn't rails_4.2.0_ new hello_app (as written in the book) work.
The only thing it says on the terminal is rails rails_4.2.0_ "command not found"?
However, when typing, rails new hello_app 4.2.0 it works. When opening the GEMFILE in the text editor I have to adjust default gems to go along with the tutorial.
Is there a different version of rails comes up?
Thanks.
Type rails -v and find out what version you have. You can also just type rails new hello app and if you have rails 4.2.0 installed then it should use that version of rails. Make sure you run bundle update if you changed your gem file.

Having some problems using Rails 3, keeps going to Rails 4

I'm relatively new to Ruby, and Rails, I need to use Rails version 3.2.19, for some tutorials I'm following along, I get all kinds of errors trying to follow along with Rails 4...anyways, when I do: gem install rails --version=3.2.19, it shows that it installed it. When I do rails -v, it shows Rails 4.1.5....I thought maybe if I create a new Rails app, specifying version 3.2.19, that would work. Surprise, it showed up as Rails 4.1.5 in my Gemfile...what gives? I tried manually changing it in the Gemfile and running bundle install, but then everything breaks when I fire up the Rails server...I searched those errors on here, and no surprise, all the answers were about how those are errors when trying to use Rails 3, in an app that was generated with Rails 4.
I'm really stumped about this folks and would appreciate any help! Thanks in advance!
1)please install rvm if YES,check the rvm ls
and set ruby 1.9.3 as default.and then make new project
2)can you see the which version of ruby using if 2+ then it will be rails 4
if you want to use rails 3 then use 1.9.3 ...
Are you doing rails _3.2.19_ new myapp
when you're generating your app?
Also when you change rails version on your Gemfile, you have to run bundle update rails to update the version.

/config/initializers/secret_token.rb not being generated. Why not?

Currently going through a rails tutorial and I need to make some modifications to /config/initializers/secret_token.rb, however, I can't find this file anywhere within the initializers directory. I am running the latest version of rails. This is the line I used in the terminal to create a rails project:
rails new sample_app
Anyone know why it isn't showing up?
Thanks for pointing this out. The issue is probably due to using Rails 4.1 instead of Rails 4.0 as specified in the Rails Tutorial. It's because of issues like this that Section 1.2.2 states (bold in original)
Unless otherwise noted, you should use the exact versions of all software used in the tutorial, including Rails itself, if you want the same results.
To get things to work, first uninstall the current version of Rails:
$ gem uninstall rails railties
Then follow the instructions exactly as written in the tutorial to install Rails 4.0:
$ gem install rails --version 4.0.4
Generating a test app (skipping Bundler for convenience) and piping the output through grep then verifies that secret_token.rb gets generated:
$ rails -v
Rails 4.0.4
$ rails new test_app --skip-bundle | grep secret_token
create config/initializers/secret_token.rb
At this point, you should be able to follow the rest of the tutorial as written.
By the way, I'm about to start work on a 3rd edition of the tutorial, and will plan to take care of this issue as part of a more general update.
The tutorial you're looking at was likely written for an older version of Rails than you're using.
secret_token.rb existed in Rails 3 and Rails 4.0 apps; it does not exist in Rails 4.1 apps.
It has been replaced in Rails 4.1 by the secrets.yml file:
http://guides.rubyonrails.org/upgrading_ruby_on_rails.html#config-secrets-yml
I am using 4.1.1. Dont copy nothing to the secrets.yml, just dont forget to update the gitignore file (http://www.railstutorial.org/book/beginning#code-gitignore)
With this you can keep going on the tutorial

Rails / Rack / Config.ru

Trying to follow the "Ruby on Rails 3 Tutorial" and running rails s, getting the following error:
[path]\config.ru:1 in 'require': no such file to load -- fake_app
I've got the location of fake_app.rb in the PATH (which I presume is what rails/rack is trying to find)
Contents of config.ru are the default generated:
require "fake_app"
run Rack::Test::FakeApp
I am running rails 3.0.8 and Windows 7
Thanks for helping this complete novice out!
Did you generate this with rails new [appname] command? A default Rails 3.0 config.ru file should look more like this:
require ::File.expand_path('../config/environment', __FILE__)
run ApplicationName::Application
If all you've done at this point is install Ruby and Rails, I'd re-run the generator to get something that works.
Also, since you're on Windows, I wanted to recommend Rails Installer for your environment installation and setup. It mitigates a lot of the startup pain.
This is probably the tutorial you are speaking of, but I also highly recommend Michael Hartl's Ruby on Rails Tutorial for a solid introduction to Rails 3. The section about generating your first application may be handy in this situation.

Why does Ruby "script/generate" return "No such file or directory"?

I am having trouble using script/generate. I am following the tree based navigation tutorial, which says to use script/plugin install git://github.com/rails/acts_as_tree.git or script/generate nifty_layout.
I keep getting:
No such file or directory -- script/plugin
I've tried these variations:
script/generate nifty_layout
rails generate nifty_layout
ruby script/generate nifty_layout
ruby generate nifty_layout
and they all tell me:
-bash: script/generate: No such file or directory
Am I missing something? Total ruby nuby here and I just can't seem to find an answer.
edit: rails 3 on Mac OS X 10.6
Rails 3 is your problem (or rather the cause of). Since rails 3 all of the "script/whatever" commands have been replaced with "rails whatever".
So now you want "rails generate ..." or "rails server" instead.
Be sure to watch version numbers or post dates when looking at tutorials :)
linkage:
Missing script/generate in Rails 3
There is a LOT of out-of-date information on the interwebs for Rails now as a result of it evolving quickly and being so popular. I use the Ruby on Rails Guides as my first stop for information as those pages seem to be the most current.
The rails generate info seems current.
you may try a couple things, first, make sure since you are using rails 3 that you have run 'bundle install'. depending on how you installed rails and which version of bundler you are using, it may not be finding your rails binary to execute the rails generate .. so you may try prefixing it with bundle exec rails g but that is deprecated and you should get a warning if you call it. Also, make sure you are following ryan's instructions for rails 3 (and run bundle install once you add to the gemfile) on his library: https://github.com/ryanb/nifty-generators
As a shortcut to rails server, you can use 'rails s'. Similarly for the console, 'rails c'.

Resources