On 24 April 2011 17:29, amrit pal pathak <[email protected]> wrote: > ... > i read again and now try it myself.Exactly follow the > tutorils and try to make changes in new ror app.please go through what > i have done. > 1) add following content to index method of home controller > class HomeController < ApplicationController > > def index > @home = Home.new > > respond_to do |format| > format.html # new.html.erb > format.xml { render :xml => @home } > end > end > end > > 2)Add following to the index.html.erb file inside home view > <h1>New post</h1> > > <%= render 'form' %> > > <%= link_to 'Back'%> > > 3)Created a new file inside app/view/home/_form.html.erb and added > following .(just copy/paste and changed the name according to my > methods and controller) > <%= form_for(@home) do |f| %> > <% if @home.errors.any? %> > <div id="error_explanation"> > <h2><%= pluralize(@home.errors.count, "error") %> prohibited > this home from being saved:</h2> > > <ul> > <% @home.errors.full_messages.each do |msg| %> > <li><%= msg %></li> > <% end %> > </ul> > </div> > <% end %> > > <div class="field"> > <%= f.label :name %><br /> > <%= f.text_field :name %> > </div> > <div class="field"> > <%= f.label :title %><br /> > <%= f.text_field :title %> > </div> > <div class="field"> > <%= f.label :content %><br /> > <%= f.text_area :content %> > </div> > <div class="actions"> > <%= f.submit %> > </div> > <% end %> > > Now i got a error ,it says > > uninitialized constant HomeController::Home > app/controllers/home_controller.rb:4:in `index' > > > Please guide me here.where is error?
I presume that it is the line @home = Home.new that is failing. That line makes a new object of class Home. That would normally be a model class. Have you defined a model called Home (it would be in models/home.rb). Colin -- 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.

