Topic: 4 Days on Rails Woes

Hi!  I'm 3 days old trying to figure out rails and really frustrated.  Everybody makes it out to be a magic language, but I'm not seeing it yet.  My web design experience is all in C# ASP.NET / Visual Studio...  I found 4 Days on Rails but am having problems with this as well.I'm pretty much using the

Re: 4 Days on Rails Woes

Ouch, I had this big long post, but it truncated it majorly and I lost A TON of it.  Knew I should have copied it.  I'll start over and this time copy before posting.

Re: 4 Days on Rails Woes

cont...

I'm pretty much using the default env from the "Getting Started on Rails" guide:  Fedora / Mongrel / SQLite.  The 4 Day guide uses Winders / Apache / MySQL.  So I was wondering if someone could follow my logic and correct when wrong.

So I start by creating the ToDo app:

1) rails ToDo

Then I create my db:

2)  rake db:create

He wants me to create a table now, but his code won't work in SQLite, so I follow his next steps planning to get the table in there with the automated way RoR does this:

3)  ruby script/generate model Category
4)  ruby script/generate controller category

Step 3 generated a db/migrate/20100716103138_create_categories.rb for creating the table.  So I modify this file to be:

class CreateCategories < ActiveRecord::Migration
  def self.up
    create_table :categories do |t|
      t.string :category
      t.references :category
      t.timestamps
    end
  end
  def self.down
    drop_table :categories
  end
end

The "t.string :category" should create me a varchar type of column, the t.references :category should make a category_id key, and the t.timestamps should create created_at and updated_at fields like he has.  So then to create it, I:

5)  rake db:migrate

Next I do like he says and modify my app/controllers/category_controller.rb file to be:

class CategoryController < ApplicationController
  model :category
  scaffold :category
end

And since I'm not using apache, I have to start my webserver (mongrel):

6)  script/server -r

Now that this is started, I try to go to my website at http://myServer:3000, but of course that's the default index.html that tells me to set my routes.  I have no clue what to set them to based on the 4 day toot.  He never talks about setting the default page, only changes where apache points to go to the public folder.  Well index.html is in there.  When he browses though, he goes to category under the public folder.  Well I don't even have a category file or folder under my public folder.

I'm lost, can someone please let me know all of the places where I messed up?

Thanks,
Eric

Re: 4 Days on Rails Woes

You're using very outdated tutorial...

I would recommend starting all over by reading this http://railstutorial.org/ as it's most up to date (rails v2.3.8) + if you want you can read this book for rails 3 - http://railstutorial.org/book?version=3.0.0.beta.

Re: 4 Days on Rails Woes

Could you post a link to the tutorial which you are following?

Re: 4 Days on Rails Woes

I started here:

http://rails.homelinux.org/

The links didn't work, so I googled Rails4Days.pdf and got:

http://topfunky.com/article/150/Rails4Days.pdf

But the original reference came from:

http://mashable.com/2007/09/30/ruby-on-rails-toolbox/


Now I'm wondering if there's a better GUI development tool than:

http://aptana.com/products/studio2/download

Thanks for the replies guys!

Eric

Re: 4 Days on Rails Woes

As I said before this tutorial is way out of date so keep as far as possible from it smile

About IDE's: I'm using http://netbeans.org/ and sometimes http://redcareditor.com/.

Re: 4 Days on Rails Woes

Thanks andain!  I'm going to go through the Rails Tutorial Book.  I've found, though, that I can't get to anything past the first chapter.  Are the other chapters available online?  Doesn't look like the book is out either as I have Safari Books Online and this one doesn't show for Michael Hartl.  Thanks again!

Re: 4 Days on Rails Woes

If you want to use a full IDE I would recommend NetBeans.  For a tutorial look at something like http://net.tutsplus.com/tutorials/other … -on-rails/

Re: 4 Days on Rails Woes

stonkers wrote:

I'm going to go through the Rails Tutorial Book.  I've found, though, that I can't get to anything past the first chapter.  Are the other chapters available online?

All chapters are available. Just go to the http://railstutorial.org/book and at the start there will be content of entire book. You can even get it in pdf:
* for 2.3.8 - http://railstutorial.org/ruby-on-rails- … -2.3.8.pdf
* for 3.0.0.beta - http://railstutorial.org/ruby-on-rails- … 0.beta.pdf

Last edited by andain (2010-07-16 16:23:56)

Re: 4 Days on Rails Woes

Ouch, I'm working through it but we're running fedora and can't seem to get past 1.8.6 of ruby.  We have no problems getting to rails 2.3.8, but ruby won't upgrade.  Any suggestions?

Re: 4 Days on Rails Woes

Install RVM.  http://rvm.beginrescueend.com/rvm/

Re: 4 Days on Rails Woes

Thanks for the information I wasnt understanding that tutorial either

Re: 4 Days on Rails Woes

OK, I installed RVM for all system users as root and put 1.8.7-p299 on there.  It shows when I do >rvm list.  However, when I do >ruby -v, I still get 1.8.6.  I don't really understand how RVM is working with versions of ruby...  More help?

Thanks,
Eric

Re: 4 Days on Rails Woes

You should type in your terminal:

rvm 1.8.7-p299

This will switch over to version 1.8.7-p299 of Ruby.  Now type:

ruby -v

You must then install the gems that your application needs. Even if you have previously installed the gems, you have to do so for this version of Ruby as each version of Ruby keeps it's own set of gems.

IMPORTANT:  Do not use sudo when installing gems under RVM.

When you open up a new shell you will be back on your systems default Ruby version (1.8.6).  You can then just switch versions with RVM again or to make 1.8.7 load as the default run:

rvm 1.8.7-p299 --default

Re: 4 Days on Rails Woes

You have new mail in /var/spool/mail/root
[root@autobot ~]# rvm 1.8.7-p299
[root@autobot ~]# ruby -v
ruby 1.8.6 (2010-02-05 patchlevel 399) [i386-linux]
[root@autobot ~]# rvm 1.8.7-p299 --default
[root@autobot ~]# ruby -v
ruby 1.8.6 (2010-02-05 patchlevel 399) [i386-linux]
[root@autobot ~]#
[root@autobot ~]# rails -v
Rails 2.3.8


I've got the right version of rails, however, it doesn't seem possible to get to the correct version of ruby from here.

Re: 4 Days on Rails Woes

Note that I am running Fedora Core 13

Re: 4 Days on Rails Woes

Did you complete the post-install instructions on http://rvm.beginrescueend.com/rvm/install/

Re: 4 Days on Rails Woes

No I didn't.  Kind of late now, though, I've moved over to Ubuntu.  Thanks for trying.  I run ubuntu at home anyway, so it will be much more familiar territory.  Thanks for trying!  Hopefully, setup will go much more smoothely...