On Apr 26, 5:09 am, Colin Law <clan...@googlemail.com> wrote:
> On 26 April 2011 09:59, amrit pal pathak <amritpalpath...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
>
>
> > On Apr 26, 4:44 am, Colin Law <clan...@googlemail.com> wrote:
> >> On 26 April 2011 09:41, amrit pal pathak <amritpalpath...@gmail.com> wrote:
>
> >> > On Apr 26, 4:30 am, amrit pal pathak <amritpalpath...@gmail.com>
> >> > wrote:
> >> >> Afer removing that block(from index.html.erb) ,i can see localhost:
> >> >> 3000/book ,but when i click on "New book" link it gave follwoing error
>
> >> >> NoMethodError in Book#new
>
> >> >> Showing /home/amrit/boook/app/views/book/_form.html.erb where line #1
> >> >> raised:
>
> >> >> undefined method `model_name' for NilClass:Class
> >> >             Should creation of model by "rails generate model book"
> >> > will resolve this error??
>
> >> You already have a Book model so no point generating it again.
>
> >         Yes you are right
>
> >> You have had this error before, please read the error carefully.  It
> >> says that something is nil that should not be.
> >       Nil means it says db has nothing to show or else??
>
> Nothing to do with the database directly, it is saying a variable that
> you are using is nil.  Look at where you setup the variable that is
> nil to find out why.
>
> >> Earlier I suggested using ruby-debug to break into your code to see
> >> what is going on.  What do you see if you break in at this point in
> >> the code?
> >         I used the rails console it says
>
> >  amrit@ubuntu:~/boook$ rails console
> > Loading development environment (Rails 3.0.7)
> > irb(main):001:0> Book.all
> > => []
>
> That is saying that there are no books in the database, but that is
> not necessarily anything to do with your problem.  As I said earlier
> look at where you are setting up the variable that is nil.
                             is it saying @book variablei is nil?
   it is defined in controller as :

 class BookController < ApplicationController
  def index
  @book =Book.new
  end
  end
                                                One thing more,in
new.html.erb,i have written "render 'form' ",but there is no such file
(view).The file there is _form.html.erb.Is it correct?

Amrit pal

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

Reply via email to