Forum: Ruby on Rails How to Generate Controllers from the command line

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
78947e02afdcaabbda360f9d112bfbe0?d=identicon&s=25 Musdev Musdev (devrubygem)
on 2009-02-19 18:26
Am I doing this correct.

ruby script/generate controller Site index about help

after I run the line above from the command prompt it spits out

exists app/controllers/
exist app/helpers/
create app/views/site
Etc.........

What does exists and create mean, is exists telling me that those
controllers now exists, and is create telling me I need to create
controllers? How do I create controllers for views and so forth?

I'm building my first app from a book called RailsSpace

Thanks
D188e591eac11021329b8821a5f954c7?d=identicon&s=25 Ar Chron (railsdog)
on 2009-02-19 18:45
Simply put, those messages are the generator telling you what it
found...

The app/controllers folder already exists.
The app/helpers folder already exists.
The app/views/site folder did not exist, and was created

Your controller is the glue between the model and the views for that
model...

Start a new rails project, and

ruby script/generate scaffold song artist:string duration:integer
genre:string

and see what gets created (all sorts of wonderful things). Peruse the
folder hierarchy and see what the parts are, and where they get created
- songs controller, song model, song views, it's all there, albeit in a
very basic format.

Many folks disparage using scaffold, but it's a great learning tool for
seeing a fully build out example.
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-02-19 18:48
(Received via mailing list)
On 19 Feb 2009, at 17:26, Zayd Connor wrote:

> Etc.........
>
> What does exists and create mean, is exists telling me that those
> controllers now exists, and is create telling me I need to create
> controllers? How do I create controllers for views and so forth?
>

it's saying that the app/controllers folder already existed but that
it had to create the app/views/site folder

Fred
82ade93bd34b4d7c756ecd1ca95eeeef?d=identicon&s=25 Master Chief (Guest)
on 2009-02-19 19:14
(Received via mailing list)
Being a newbie myself, I will add a word of caution.

Compare the version the book is based on, with what you are running. I
was on Rails 2.2.2 and its syntax for scaffold generation is different
from the earlier versions in the sense that the attributes are
expected in the command line now.

I learnt that the hard way.
So if you are using the latest and greatest, read the book with a
pinch of salt and check the net when in doubt!

Hope this helps.
I am using Rails 2.2.2 on Ruby 1.8.6 using MySQL 5.0 on WinXP. This
config just works for me.

Aside: Started off with Komodo and then  jRuby on NetBeans IDE , using
MySQL 6.0 on Vista 64-bit but it was a mess cause half the time the
IDE was tripping me up and some gems/plugins wouldnt install
correctly. Dont know if it was because of Vista or NetBeans on 64-bit.
I had to use MySQL 6.0 as that is the only one which would run on
Vista 64-bit.  but then some Rails stuff was not certified for mySQL
6.0 so ultimately I got out of that rat hole.

cheers
On Feb 19, 9:47 am, Frederick Cheung <frederick.che...@gmail.com>
78947e02afdcaabbda360f9d112bfbe0?d=identicon&s=25 Musdev Musdev (devrubygem)
on 2009-02-20 01:08
Master Chief wrote:
> Being a newbie myself, I will add a word of caution.
>
> Compare the version the book is based on, with what you are running. I
> was on Rails 2.2.2 and its syntax for scaffold generation is different
> from the earlier versions in the sense that the attributes are
> expected in the command line now.
>
> I learnt that the hard way.
> So if you are using the latest and greatest, read the book with a
> pinch of salt and check the net when in doubt!
>
> Hope this helps.
> I am using Rails 2.2.2 on Ruby 1.8.6 using MySQL 5.0 on WinXP. This
> config just works for me.
>
> Aside: Started off with Komodo and then  jRuby on NetBeans IDE , using
> MySQL 6.0 on Vista 64-bit but it was a mess cause half the time the
> IDE was tripping me up and some gems/plugins wouldnt install
> correctly. Dont know if it was because of Vista or NetBeans on 64-bit.
> I had to use MySQL 6.0 as that is the only one which would run on
> Vista 64-bit.  but then some Rails stuff was not certified for mySQL
> 6.0 so ultimately I got out of that rat hole.
>
> cheers
> On Feb 19, 9:47�am, Frederick Cheung <frederick.che...@gmail.com>


Thanks Guys that helped me out alot. I have the same set up. I'm also
using rails 2.2.  Im not so proficient in the ruby language,I know how
to deal with arrays, hashes, code blocks, functions, basic stuff nothing
fancy at all. Should I be concentrating more on the ruby language
instead of moving so fast to rail projects?

Thanks
82ade93bd34b4d7c756ecd1ca95eeeef?d=identicon&s=25 Master Chief (Guest)
on 2009-02-20 01:23
(Received via mailing list)
Hey, welcome to the club!

I am in same boat. and m learning as I go. If you know Ruby basics,
you can dive into Rails tutorials. and working on a real program then
whets your appetite.

As for myself - I am reading The Rails Way by Obie after looking at a
few other books. It gives me context around the rails constructs.
I read a book about Ruby too as that was a huge stumbling block for
me. The syntax is different  as I come from C,C++, Java world. This
book I skimmed thru as I just needed to get familiar with the
different syntax.

The rest will come as I work thru code and look at other code. That
said, everyone has their own best way of learning!

cheers from another newbie!

On Feb 19, 4:08 pm, Zayd Connor <rails-mailing-l...@andreas-s.net>
Af2ce6689213fdb78913a9662b18da6b?d=identicon&s=25 Rick (Guest)
on 2009-02-20 07:12
(Received via mailing list)
RailsSpace was written with Rails 1.1.2 and Ruby 1.8.4 but there's a
web site referenced in the book that makes the files for Rails 2
available.  The site also has an ephemeris with corrections for the
code as printed in the book.

On Feb 19, 2:08 pm, Zayd Connor <rails-mailing-l...@andreas-s.net>
This topic is locked and can not be replied to.