Good day, people,
I installed a fully working Ruby on Rails on my Debian Squeeze system
today and am studying a tutorial about Ruby on Rails right now.
It says that in the main folder of my app, I should type
ruby script/generate controller Stories index
Good, but that seems to be for older ruby versions than mine. I get a
‘file not found’ error.
So I took a little look around the directory and found that I may use:
ruby script/rails generate controller Stories index
Stories#index
Find me in app/views/stories/index.html.erb
Huh. That’s good for the time being, because something happens in some
kind and I got a functioning (at least halfway) controller. But why
won’t it use /stories/index just for the parent directory /stories –
and especially: Why doesn’t it do that as automatically by official
Ruby on Rails tools generated code? Would look some kinda stupid when
every url of my website will have /index at the end. >:s
Stories#index
Find me in app/views/stories/index.html.erb
Huh. That’s good for the time being, because something happens in some
kind and I got a functioning (at least halfway) controller. But why
won’t it use /stories/index just for the parent directory /stories –
and especially: Why doesn’t it do that as automatically by official
Ruby on Rails tools generated code? Would look some kinda stupid when
every url of my website will have /index at the end. >:s
You got exactly what you asked for - if you just ask for a controller
with an action, there’s no special casing of particular action names.
You can of course add a route specifying what should be done with /
stories. Typically you would be using resourceful routes, in which
cases /stories would be mapped to StoriesController#index for you.
(try rails generate scaffold stories name:string body:text)
ruby script/rails generate controller Stories index
By the way, this implies that you’re working with rails 3 but
following a tutorial on rails 2.x (or earlier). Rails 3 is
substantially different from rails 2 - you might want to hunt for an
up to date tutorial. guides.rubyonrails.org is a good place to start
Thanks for your answer! I’m just a little bit disappointed now that I
have to use a whole other tutorial now.
scaffold will create all things for a basic database view and editing
system, and it will create
resources :stories
in my routes.rb. Well, that’s what I did manually now. I don’t wanna
have everything pre-done for me right now, although I think scaffold
will get useful for me again.