i have cateadd.html.erb file in admins folder and i want call admins controller and define method like this def cateadd @pro_categorie = ProCategorie.new respond_to do |formate| format.html # new.html.erb format.xml { render :xml => @pro_categorie } end end pro_categories is table name i want to insert record in this table but bad luck i can not do it -- Posted via http://www.ruby-forum.com/.
Wap Addon wrote:> i have cateadd.html.erb file in admins folder and i want call admins > controller and define method like this > > > def cateadd > @pro_categorie = ProCategorie.new > respond_to do |formate| > format.html # new.html.erb > format.xml { render :xml => @pro_categorie } > end > end > > pro_categories is table name i want to insert record in this table > but bad luck i can not do itI believe rails pluralization rules may be getting confused here.. try renaming your model to "ProCategory" or add: class ProCategorie set_table_name "pro_categories" end hth ilan -- Posted via http://www.ruby-forum.com/.
On Aug 10, 3:34 pm, Wap Addon <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> i have cateadd.html.erb file in admins folder and i want call admins > controller and define method like this > > def cateadd > @pro_categorie = ProCategorie.new > respond_to do |formate| > format.html # new.html.erb > format.xml { render :xml => @pro_categorie } > endYou''ve got a typo here - formate/format Fred> end > > pro_categories is table name i want to insert record in this table > but bad luck i can not do it > -- > Posted viahttp://www.ruby-forum.com/.
Frederick Cheung wrote:> On Aug 10, 3:34�pm, Wap Addon <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: >> i have cateadd.html.erb file in admins folder and i want call admins >> controller and define method like this >> >> � � � � � �def cateadd >> � � @pro_categorie = ProCategorie.new >> � � respond_to do |formate| >> � � format.html # new.html.erb >> � � � � � � � �format.xml �{ render :xml => @pro_categorie } >> � � � � � � �end > > You''ve got a typo here - formate/format > > Fredthanks dear is it ok but when put on @pro_categorie in cateadd.html.erb is below <div> <h3 align="center">Add product category</h3> <% form_for(@pro_categorie) do |f| %> <%= f.error_messages %> <table align="center"> </tr> <td><lable>Category Name :</lable></td> <td><%= f.text_field :pcate_name %></td> </tr> <tr> <td><lable>Category Description :</lable></td> <td><%= f.text_field :pcate_desc %></td> </tr> </table> <%end%> </div> i got error Showing app/views/admins/cateadd.html.erb where line #5 raised: undefined method `pro_categories_path'' for #<ActionView::Base:0x4839358> -- Posted via http://www.ruby-forum.com/.
On Aug 11, 6:34 am, Wap Addon <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > <% form_for(@pro_categorie) do |f| %>Have you added map.resources :pro_categories in your routes.rb file ? THat''s the price you must pay to be able to use this short form. If you have then the most likely reason is rails getting confused about the pluralization Fred> <%= f.error_messages %> > <table align="center"> > </tr> > <td><lable>Category Name :</lable></td> > <td><%= f.text_field :pcate_name %></td> > </tr> > <tr> > <td><lable>Category Description :</lable></td> > <td><%= f.text_field :pcate_desc %></td> > </tr> > > </table> > <%end%> > </div> > > i got error > Showing app/views/admins/cateadd.html.erb where line #5 raised: > > undefined method `pro_categories_path'' for #<ActionView::Base:0x4839358> > -- > Posted viahttp://www.ruby-forum.com/.
Frederick Cheung wrote:> On Aug 11, 6:34�am, Wap Addon <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > >> >> � �<% form_for(@pro_categorie) do |f| %> > > Have you added map.resources :pro_categories in your routes.rb file ? > THat''s the price you must pay to be able to use this short form. If > you have then the most likely reason is rails getting confused about > the pluralization > > Fredthanks for give me right direction -- Posted via http://www.ruby-forum.com/.