Hi everyone, First I want to begin by saying I am a total newbie when it comes to Rails. I am reading Obie Fernandez''s The Rails Way, but I have a question about something he says. He says that if I have a controller like this: class DemoController < ApplicationController def index end end Even though it is empty, Rails will still render the index template (in the book he uses Rails 1.2, and the template is named index.rhtml). He says that is part of what "convention over configuration" means. All that sounds great, but when I tried it out using JRuby 1.4.0, Rails 2.3.5, glassfish gem 1.0.2, using an empty controller action similar to the one above, I got this as a result: Routing Error No route matches "/receta/index" with {:method=>:get} I kept wondering what I did wrong, so I decided to try a scaffold made controller, and see what the differences are. It turns out, that by putting my controller like this makes it work: class RecetaController < ApplicationController def index respond_to do |format| format.html # index.html.erb end end end I noticed that, contrary to the book, my template is named index.html.erb. Did that change as the versions progressed? I also can''t believe that something that is in accord to the CoC philosophy would not work in a more recent version of the framework. Why doesn''t an empty controller action render its template in my version? For that matter, is the book I''m reading still good, or is it too old and some of what is says doens''t apply any more? I love Rails, and want to become proficient in it, so any info you guys can provide will be greatly appreciated. -- Posted via http://www.ruby-forum.com/. -- 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.
Hi Tuti, You can still use a empty controller method. You just have to name it ie. index.html.erb or index.erb :) Cheers, David On Mon, Feb 8, 2010 at 9:31 AM, tuti plain <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi everyone, > > First I want to begin by saying I am a total newbie when it comes to > Rails. I am reading Obie Fernandez''s The Rails Way, but I have a > question about something he says. He says that if I have a controller > like this: > > class DemoController < ApplicationController > def index > end > end > > Even though it is empty, Rails will still render the index template > (in the book he uses Rails 1.2, and the template is named index.rhtml). > He says that is part of what "convention over configuration" means. > > All that sounds great, but when I tried it out using JRuby 1.4.0, > Rails 2.3.5, glassfish gem 1.0.2, using an empty controller action > similar to the one above, I got this as a result: > > Routing Error > > No route matches "/receta/index" with {:method=>:get} > > I kept wondering what I did wrong, so I decided to try a scaffold made > controller, and see what the differences are. It turns out, that by > putting my controller like this makes it work: > > class RecetaController < ApplicationController > def index > respond_to do |format| > format.html # index.html.erb > end > end > end > > I noticed that, contrary to the book, my template is named > index.html.erb. Did that change as the versions progressed? I also > can''t believe that something that is in accord to the CoC philosophy > would not work in a more recent version of the framework. Why doesn''t > an empty controller action render its template in my version? For that > matter, is the book I''m reading still good, or is it too old and some of > what is says doens''t apply any more? > > I love Rails, and want to become proficient in it, so any info you > guys can provide will be greatly appreciated. > -- > Posted via http://www.ruby-forum.com/. > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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.
On Mon, 2010-02-08 at 02:31 +0100, tuti plain wrote:> Hi everyone, > > First I want to begin by saying I am a total newbie when it comes to > Rails. I am reading Obie Fernandez''s The Rails Way, but I have a > question about something he says. He says that if I have a controller > like this: > > class DemoController < ApplicationController > def index > end > end > > Even though it is empty, Rails will still render the index template > (in the book he uses Rails 1.2, and the template is named index.rhtml). > He says that is part of what "convention over configuration" means. > > All that sounds great, but when I tried it out using JRuby 1.4.0, > Rails 2.3.5, glassfish gem 1.0.2, using an empty controller action > similar to the one above, I got this as a result: > > Routing Error > > No route matches "/receta/index" with {:method=>:get} > > I kept wondering what I did wrong, so I decided to try a scaffold made > controller, and see what the differences are. It turns out, that by > putting my controller like this makes it work: > > class RecetaController < ApplicationController > def index > respond_to do |format| > format.html # index.html.erb > end > end > end > > I noticed that, contrary to the book, my template is named > index.html.erb. Did that change as the versions progressed? I also > can''t believe that something that is in accord to the CoC philosophy > would not work in a more recent version of the framework. Why doesn''t > an empty controller action render its template in my version? For that > matter, is the book I''m reading still good, or is it too old and some of > what is says doens''t apply any more? > > I love Rails, and want to become proficient in it, so any info you > guys can provide will be greatly appreciated.---- I am not exactly sure what is meant by CoC, Continuity of Code? If that''s the case, don''t count on it because many things changed from 1.2 to 2.x 2.0 release notes http://weblog.rubyonrails.org/2007/12/7/rails-2-0-it-s-done 2.3 release notes http://guides.rubyonrails.org/2_3_release_notes.html if you are determined to play along with an outdated book that uses an outdated version of Rails, you might consider installing and using an outdated version of Rails... gem install rails --version 1.2.6 (I think is the command...going from flaky memory) Then you would have to instruct rails to use a different version (check out the ''rake --tasks'' command) or you can try to deduce the changes from the release notes offered above. Craig -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- 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.
tuti plain wrote:> Hi everyone, > > First I want to begin by saying I am a total newbie when it comes to > Rails. I am reading Obie Fernandez''s The Rails Way, but I have a > question about something he says. He says that if I have a controller > like this: > > class DemoController < ApplicationController > def index > end > end > > Even though it is empty, Rails will still render the index template > (in the book he uses Rails 1.2, and the template is named index.rhtml). > He says that is part of what "convention over configuration" means. > > All that sounds great, but when I tried it out using JRuby 1.4.0, > Rails 2.3.5, glassfish gem 1.0.2, using an empty controller action > similar to the one above, I got this as a result: > > Routing Error > > No route matches "/receta/index" with {:method=>:get}What''s the output from rake routes? The example should still work in Rails 2.x, provided your routes are correct.> > I kept wondering what I did wrong, so I decided to try a scaffold made > controller, and see what the differences are. It turns out, that by > putting my controller like this makes it work: > > class RecetaController < ApplicationController > def index > respond_to do |format| > format.html # index.html.erb > end > end > end > > I noticed that, contrary to the book, my template is named > index.html.erb. Did that change as the versions progressed?It certainly did. The .rhtml suffix will still work in Rails 2.x, but is deprecated.> I also > can''t believe that something that is in accord to the CoC philosophy > would not work in a more recent version of the framework. Why doesn''t > an empty controller action render its template in my version?It still should. I think you''re just having a routing issue.> For that > matter, is the book I''m reading still good, or is it too old and some of > what is says doens''t apply any more? >Rails 2.x is very different from Rails 1.x. Try to find an up-to-date book. http://guides.rails.info is also a great place to start.> I love Rails, and want to become proficient in it, so any info you > guys can provide will be greatly appreciated.Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- 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.
> I am not exactly sure what is meant by CoC, Continuity of Code?CoC means "convention over configuration", which is supposed to be one of Rails'' founding philosophies.> if you are determined to play along with an outdated book that uses an > outdated version of Rails, you might consider installing and using an > outdated version of Rails...It''s not that I''m determined to play with an outdated book, I just thought, this book was the de facto reference for Rails, but I guess I might have been wrong about it.>Hi Tuti,>You can still use a empty controller method.>You just have to name it ie. index.html.erb or index.erb :)That is exactly what I had, but it didn''t work until I added the respond_to code. Not that I intend to have empty controller methods, but I''d still like to know why it didn''t function.>Rails 2.x is very different from Rails 1.x. Try to find an up-to-date >book. http://guides.rails.info is also a great place to start.I had been on this page before and tried out the first tutorials. Guess I''ll go more in depth. Thanks for your replies! -- Posted via http://www.ruby-forum.com/. -- 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.
The Rails Way certainly is the de facto Rails book... but for Rails 1.2. I''m pretty sure it was never updated for 2.x, but I could be wrong. My copy is for 1.2. In any case, yeah, as everyone else said, it should work. The "rake routes" suggestion is a good one, since you''re seeing a routing error. -- 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.
I have a version of the book with something that looks like a circular stamp on the cover that says "Covers Rails 2.0", so I guess it has been updated. ;) And I would have to agree with Marnen. It looks like you have a routing issue. Cheers. On Feb 8, 8:16 am, tuti plain <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> > I am not exactly sure what is meant by CoC, Continuity of Code? > > CoC means "convention over configuration", which is supposed to be one > of Rails'' founding philosophies. > > > if you are determined to play along with an outdated book that uses an > > outdated version of Rails, you might consider installing and using an > > outdated version of Rails... > > It''s not that I''m determined to play with an outdated book, I just > thought, this book was the de facto reference for Rails, but I guess I > might have been wrong about it. > > >Hi Tuti, > >You can still use a empty controller method. > >You just have to name it ie. index.html.erb or index.erb :) > > That is exactly what I had, but it didn''t work until I added the > respond_to code. Not that I intend to have empty controller methods, > but I''d still like to know why it didn''t function. > > >Rails 2.x is very different from Rails 1.x. Try to find an up-to-date > >book. http://guides.rails.infois also a great place to start. > > I had been on this page before and tried out the first tutorials. > Guess I''ll go more in depth. > > Thanks for your replies! > -- > Posted viahttp://www.ruby-forum.com/.-- 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.
> I have a version of the book with something that looks like a circular > stamp on the cover that says "Covers Rails 2.0", so I guess it has > been updated. ;) > > And I would have to agree with Marnen. It looks like you have a > routing issue. > > Cheers.Mine has it, too. The author clarifies in the first chapter, that he used edge Rails to cover 2.0 features at the time of writing, so it is likely that it does not cover all 2.x features. -- Posted via http://www.ruby-forum.com/. -- 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.