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 <[email protected]> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-talk%[email protected]>
> .
> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to