Rails / Rack / Config.ru - ruby-on-rails

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.

Related

/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

Getting specific Rails version of a Rails 2.x app

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'

How to start and setup Ruby On Rails development with eclipse

I am having excellent experience in Java and eclipse, But new to Ruby on Rails, can anyone point to the best resources, or step which i can follow to start with Ruby On Rails development and enviornment setup for windows.
I think Rails Tutorial is a best place for you to start learning, setup environment and development for Ruby on Rails:
Rails Tutorial
Rails Guide and about API
Some videos Rails Cast
Book Rails 3 way
One more thing, I think many Rails developers will not build Rails application on Window.
I have been using it fine. You just have to setup the correct run config to run rails -s

Rails not launching web page

I have just started to learn Ruby on Rails and in going through a tutorial I am not able to launch the rails project because of the following error.
-e:4:in `load': no such file to load -- script/server (LoadError)
from -e:4:in `<main>'
I have installed Ruby 1.9.2 and using RadRails as the IDE for creating and executing the Rails project. Any suggestions?
Most likely your tutorial refers to Rails 2 (for which given command works), while you're using Rails 3.
I'm not sure how exactly you start server in Rails 3 (edit see answer by jdl), but take my adice: find another tutorial. Otherwise, you'll have to create such questions here several times a day :)
If you just installed the latest Rails the the command has changed (as of Rails 3) to:
$ ./script/rails server
I think the best way to start a server in Rails 3 is to run this command from the root of the project:
rails server
You should have the rails executable in your path if you've installed the Rails 3 gem.

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