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
Now I get the following:
create app/controllers/stories_controller.rb
route get "stories/index"
invoke erb
create app/views/stories
create app/views/stories/index.html.erb
invoke test_unit
create test/functional/stories_controller_test.rb
invoke helper
create app/helpers/stories_helper.rb
invoke test_unit
create test/unit/helpers/stories_helper_test.rb
Good! Then it''s said that I should go to http://localhost:3000/stories
where I would find a quite empty starting page. But the only thing
I''ll get is
Routing Error
No route matches "/stories"
I thought for a second and typed in http://localhost:3000/stories/index
, and I get
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
Regards,
Simon
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2011-Mar-13 10:54 UTC
Re: Problem with auto-generated controller and index
On Mar 12, 11:25 pm, Simon Welker <p0mmesg4...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> 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) Fred Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2011-Mar-13 10:56 UTC
Re: Problem with auto-generated controller and index
On Mar 12, 11:25 pm, Simon Welker <p0mmesg4...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> 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 indexBy 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 Fred> > Now I get the following: > > create app/controllers/stories_controller.rb > route get "stories/index" > invoke erb > create app/views/stories > create app/views/stories/index.html.erb > invoke test_unit > create test/functional/stories_controller_test.rb > invoke helper > create app/helpers/stories_helper.rb > invoke test_unit > create test/unit/helpers/stories_helper_test.rb > > Good! Then it''s said that I should go tohttp://localhost:3000/stories > where I would find a quite empty starting page. But the only thing > I''ll get is > > Routing Error > No route matches "/stories" > > I thought for a second and typed inhttp://localhost:3000/stories/index > , and I get > > 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 > > Regards, > Simon-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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. Thank you! :) On 13 Mrz., 11:56, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Mar 12, 11:25 pm, Simon Welker <p0mmesg4...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > 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 > > 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 > > Fred > > > > > > > Now I get the following: > > > create app/controllers/stories_controller.rb > > route get "stories/index" > > invoke erb > > create app/views/stories > > create app/views/stories/index.html.erb > > invoke test_unit > > create test/functional/stories_controller_test.rb > > invoke helper > > create app/helpers/stories_helper.rb > > invoke test_unit > > create test/unit/helpers/stories_helper_test.rb > > > Good! Then it''s said that I should go tohttp://localhost:3000/stories > > where I would find a quite empty starting page. But the only thing > > I''ll get is > > > Routing Error > > No route matches "/stories" > > > I thought for a second and typed inhttp://localhost:3000/stories/index > > , and I get > > > 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 > > > Regards, > > Simon-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.