I generated controller and view as. "script/generate controller home index" Tried to make a form .Edited the index method in home controller and added follwoing stuff inside <%= form_for @home do |f| %> <%= f.label :first_name %>: <%= f.text_field :first_name %><br /> <%= f.label :last_name %>: <%= f.text_field :last_name %><br /> <%= f.submit %> <% end %> Then started the server But it didnt generate form.Am i missing anything(i hope so).Should anything be added in index.html.erb file in home view?Or else?Using rails 3.0.7.I Have read the form generation tutorils but could not understand lot.So asking here. Regards Amrit Pal Pathak Thanks -- 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 generated controller and view as. "script/generate controller home index" Tried to make a form .Edited the index method in home controller and added follwoing stuff inside <%= form_for @home do |f| %> <%= f.label :first_name %>: <%= f.text_field :first_name %><br /> <%= f.label :last_name %>: <%= f.text_field :last_name %><br /> <%= f.submit %> <% end %> Then started the server But it didnt generate form.Am i missing anything(i hope so).Should anything be added in index.html.erb file in home view?Or else?Using rails 3.0.7.I Have read the form generation tutorils but could not understand lot.So asking here. Regards Amrit Pal Pathak Thanks -- 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 generated controller and view as. "script/generate controller home index" Tried to make a form .Edited the index method in home controller and added follwoing stuff inside <%= form_for @home do |f| %> <%= f.label :first_name %>: <%= f.text_field :first_name %><br /> <%= f.label :last_name %>: <%= f.text_field :last_name %><br /> <%= f.submit %> <% end %> Then started the server But it didnt generate form.Am i missing anything(i hope so).Should anything be added in index.html.erb file in home view?Or else?Using rails 3.0.7.I Have read the form generation tutorils but could not understand lot.So asking here. Regards Amrit Pal Pathak Thanks -- 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 24 April 2011 10:28, amrit pal pathak <amritpalpathak1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I generated controller and view as. > "script/generate controller home index" > > > Tried to make a form .Edited the index method in home controller and > added follwoing stuff insideYou added the code below to the index method of the home controller (so in controllers/home_controller.rb)? If so then it is not surprising it did not work. Where did you put it?> > <%= form_for @home do |f| %> > <%= f.label :first_name %>: > <%= f.text_field :first_name %><br /> > > <%= f.label :last_name %>: > <%= f.text_field :last_name %><br /> > > <%= f.submit %> > <% end %> > > Then started the server But it didnt generate form.Am i missing > anything(i hope so).Should anything be added in index.html.erb file in > home view?Or else?Using rails 3.0.7.I Have read the form generation > tutorils but could not understand lot.So asking here.What do you see if you look at the html generated by the above (assuming you have actually put it in one of the views)? In the browser do View > Page Source or similar (dependant on browser). 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 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.
On Apr 24, 7:25 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 24 April 2011 10:28, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I generated controller and view as. > > "script/generate controller home index" > > > Tried to make a form .Edited the index method in home controller and > > added follwoing stuff inside > > You added the code below to the index method of the home controller > (so in controllers/home_controller.rb)? If so then it is not > surprising it did not work. Where did you put it?Yes it put in index method of home controller.(Seemz it is wrong). Can you please tell me where to put it(in index.html.erb ) (view)? Thanks . -- 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.
On 24 April 2011 13:23, amrit pal pathak <amritpalpathak1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Apr 24, 7:25 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> On 24 April 2011 10:28, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> > I generated controller and view as. >> > "script/generate controller home index" >> >> > Tried to make a form .Edited the index method in home controller and >> > added follwoing stuff inside >> >> You added the code below to the index method of the home controller >> (so in controllers/home_controller.rb)? If so then it is not >> surprising it did not work. Where did you put it? > > Yes it put in index method of home controller.(Seemz it is > wrong). > Can you please tell me where to put it(in index.html.erb ) > (view)?I think you said that you worked through the Rails Guide on getting started. Is that correct? Did you really work right through it, examining the code generated by the scaffolding, making sure you understood everything there, and experimenting with small changes to make sure you understand what is going on? If so then I cannot understand how you do not know that code that generates a form for display in the browser must go in one of the view files. *Please* work through the getting started guide again and make sure you understand it. That way will save us all a lot of time. Once you have worked through that guide then find a more complex one (I think I recommended the free-to-use-online one at railstutorial.org previously) and work through that. 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 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.
On Apr 24, 8:36 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 24 April 2011 13:23, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > > > > On Apr 24, 7:25 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > >> On 24 April 2011 10:28, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >> > I generated controller and view as. > >> > "script/generate controller home index" > > >> > Tried to make a form .Edited the index method in home controller and > >> > added follwoing stuff inside > > >> You added the code below to the index method of the home controller > >> (so in controllers/home_controller.rb)? If so then it is not > >> surprising it did not work. Where did you put it? > > > Yes it put in index method of home controller.(Seemz it is > > wrong). > > Can you please tell me where to put it(in index.html.erb ) > > (view)? > > I think you said that you worked through the Rails Guide on getting > started. Is that correct? Did you really work right through it, > examining the code generated by the scaffolding, making sure you > understood everything there, and experimenting with small changes to > make sure you understand what is going on? If so then I cannot > understand how you do not know that code that generates a form for > display in the browser must go in one of the view files. *Please* > work through the getting started guide again and make sure you > understand it. That way will save us all a lot of time. > > Once you have worked through that guide then find a more complex one > (I think I recommended the free-to-use-online one at railstutorial.org > previously) and work through that. >Ok i will again go through tutorial and understand again.Will try to edit . Thanks -- 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.
On Apr 24, 12:22 pm, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Apr 24, 8:36 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > > > > > > > > On 24 April 2011 13:23, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > On Apr 24, 7:25 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > >> On 24 April 2011 10:28, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > >> > I generated controller and view as. > > >> > "script/generate controller home index" > > > >> > Tried to make a form .Edited the index method in home controller and > > >> > added follwoing stuff inside > > > >> You added the code below to the index method of the home controller > > >> (so in controllers/home_controller.rb)? If so then it is not > > >> surprising it did not work. Where did you put it? > > > > Yes it put in index method of home controller.(Seemz it is > > > wrong). > > > Can you please tell me where to put it(in index.html.erb ) > > > (view)? > > > I think you said that you worked through the Rails Guide on getting > > started. Is that correct? Did you really work right through it, > > examining the code generated by the scaffolding, making sure you > > understood everything there, and experimenting with small changes to > > make sure you understand what is going on? If so then I cannot > > understand how you do not know that code that generates a form for > > display in the browser must go in one of the view files. *Please* > > work through the getting started guide again and make sure you > > understand it. That way will save us all a lot of time. > > > Once you have worked through that guide then find a more complex one > > (I think I recommended the free-to-use-online one at railstutorial.org > > previously) and work through that. >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? Thanks -- 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.
On 24 April 2011 17:29, amrit pal pathak <amritpalpathak1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 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.
On Apr 24, 1:07 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 24 April 2011 17:29, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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).I generated a model using "rails generate model home" ,it generated follwoing files amrit@ubuntu:~/demo$ rails generate model home invoke active_record create db/migrate/20110425113449_create_homes.rb create app/models/home.rb invoke test_unit create test/unit/home_test.rb create test/fixtures/homes.yml Then i perform migrations using "rake db:migrate",it gave (Table homes is created) (in /home/amrit/demo) == CreateHomes: migrating ===================================================-- create_table(:homes) -> 0.0714s == CreateHomes: migrated (0.0717s) ========================================== So started the server now ,it gave follwoing error message NoMethodError in Home#index Showing /home/amrit/demo/app/views/home/_form.html.erb where line #1 raised: undefined method `homes_path'' for #<#<Class:0xb6788a3c>:0xb678790c> Content of /app/view/home/_form.html.erb file are as; <%= 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 %> Thanks -- 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.