Faisal Basha
2010-Sep-19 18:03 UTC
Missing template classified/update.erb in view path app/view
Iam trying to build a classified site, I''ve created the code to add,edit,delete posts. I am facing trouble with the edit part. When I click the edit link for a post it shows the form with all the textfields,after entering in all the fields and clicking the save changes button, Iam getting the error: "Missing template classified/update.erb in view path app/view" Update function in the controller looks like: def update @classifed = Classified.find(params[:id]) if @classified.update_attributes(params[:classified]) redirect_to :action => ''show'', :id => @classified else render :action => ''edit'' end end show.rhtml looks like <h1>Editing Classified: <%= :title -%></h1> <% form_for :classified, :url => {:action => ''update''} do |form| %> <p><label for="classified_title">Title</label><br/> <%= form.text_field :title %></p> <p><label for="classified_price">price</label><br/> <%= form.text_field :price %></p> <p><label for ="classified_location">Location</label><br/> <%= form.text_field :location %></p> <p><label for ="classified_description">Description</label><br/> <%= form.text_area :description %></p> <p><label for ="classified_email">Email</label><br/> <%= form.text_field :email %></p> <%= submit_tag "save changes" %> <% end %> <%= link_to ''Back'', {:action => ''list''} %> Help will be appreciated. Thanks -- 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 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.
steve ross
2010-Sep-19 19:42 UTC
Re: Missing template classified/update.erb in view path app/view
Typically your show action does not allow for user input. The edit action does. In any case, is there a classified/edit.erb and if you are trying to render it, then it implies that the update failed. Do you know why? On Sep 19, 2010, at 11:03 AM, Faisal Basha wrote:> Iam trying to build a classified site, I''ve created the code to > add,edit,delete posts. I am facing trouble with the edit part. When I > click the edit link for a post it shows the form with all the > textfields,after entering in all the fields and clicking the save > changes button, Iam getting the error: > "Missing template classified/update.erb in view path app/view" > > Update function in the controller looks like: > > def update > @classifed = Classified.find(params[:id]) > if @classified.update_attributes(params[:classified]) > redirect_to :action => ''show'', :id => @classified > else > render :action => ''edit'' > end > end > > show.rhtml looks like > > <h1>Editing Classified: <%= :title -%></h1> > <% form_for :classified, :url => {:action => ''update''} do |form| %> > <p><label for="classified_title">Title</label><br/> > <%= form.text_field :title %></p> > <p><label for="classified_price">price</label><br/> > <%= form.text_field :price %></p> > <p><label for ="classified_location">Location</label><br/> > <%= form.text_field :location %></p> > <p><label for ="classified_description">Description</label><br/> > <%= form.text_area :description %></p> > <p><label for ="classified_email">Email</label><br/> > <%= form.text_field :email %></p> > > <%= submit_tag "save changes" %> > <% end %> > <%= link_to ''Back'', {:action => ''list''} %> > > Help will be appreciated. Thanks > -- > 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 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. >-- 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.
radhames brito
2010-Sep-19 21:41 UTC
Re: Missing template classified/update.erb in view path app/view
your show action looks like the edit action should look, and then you are rendering edit if something goes wrong , that is not the way def update @classifed = Classified.find(params[:id]) if @classified.update_attributes(params[:classified]) redirect_to :action => ''show'', :id => @classified else render :action => ''edit'' ========> should be render :action=> "show" end end but you have a mess there , thats the main problem, you are not been restful -- 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.
Faisal Basha
2010-Sep-20 04:40 UTC
Re: Missing template classified/update.erb in view path app/view
sorry guys, I made a typo error while posting it here. The show.rhtml file is actually named edit.rhtml, I do have another file that is show.rhtml which renders the html file. so what I really have is Update function in the controller looks like: def update @classifed = Classified.find(params[:id]) if @classified.update_attributes(params[:classified]) redirect_to :action => ''show'', :id => @classified else render :action => ''edit'' end end edit.rhtml looks like <h1>Editing Classified: <%= :title -%></h1> <% form_for :classified, :url => {:action => ''update''} do |form| %> <p><label for="classified_title">Title</label><br/> <%= form.text_field :title %></p> <p><label for="classified_price">price</label><br/> <%= form.text_field :price %></p> <p><label for ="classified_location">Location</label><br/> <%= form.text_field :location %></p> <p><label for ="classified_description">Description</label><br/> <%= form.text_area :description %></p> <p><label for ="classified_email">Email</label><br/> <%= form.text_field :email %></p> <%= submit_tag "save changes" %> <% end %> <%= link_to ''Back'', {:action => ''list''} %> Well, I''ll try replacing :action => ''edit'' with :action => ''show''. Iam not exactly sure what restful really means. My bad Iam sill a nOOb. Thanks anyways. radhames brito wrote:> your show action looks like the edit action should look, and then you > are > rendering edit if something goes wrong , that is not the way > > > def update > @classifed = Classified.find(params[:id]) > if @classified.update_attributes(params[:classified]) > redirect_to :action => ''show'', :id => @classified > else > render :action => ''edit'' ========> should be render :action=> > "show" > end > end > > but you have a mess there , thats the main problem, you are not been > restful-- 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 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.
radhames brito
2010-Sep-20 05:07 UTC
Re: Re: Missing template classified/update.erb in view path app/view
what i said was based on the fact that i thought your edit action was named show so if it was a typo ignore my comment. try making this changes and post your routes if it still does not work, and what version of rails are you using? the edit action should be def edit @classifed = Classified.find(params[:id]) end def update @classifed = Classified.find(params[:id]) if @classified.update_attributes(params[:classified]) flash[:notice] = "updated" redirect_to @classified else render :action => ''edit'' end end <h1>Editing Classified: <%= :title -%></h1> <% form_for @classified do |form| %> <%=form.error_messages%> <p> <%=form.label :title%><br/> <%= form.text_field :title %> </p> <p> <%=form.label :price%><br/> <%= form.text_field :price %> </p> <p> <%=form.label :location%><br/> <%= form.text_field :location %> </p> <p> <%=form.label :description%><br/> <%= form.text_area :description %> </p> <p> <%=form.label :email%><br/> <%= form.text_field :email %> </p> <%= submit_tag "save changes" %> <% end %> <%= link_to ''Back'', {:action => ''list''} %> in your routes.rb file it should say resources classifies, or whatever the plural should be -- 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.
Faisal Basha
2010-Sep-26 17:16 UTC
Re: Re: Missing template classified/update.erb in view path app/view
hey guys...long time I got too busy with my work...my apologies.. I tried the above code I still get errors: compile error /Users/alihan/classifieds/app/views/classified/edit.rhtml:5: syntax error, unexpected ''>'' /Users/alihan/classifieds/app/views/classified/edit.rhtml:10: syntax error, unexpected tIDENTIFIER, expecting '')'' <%= form.text_field :price ).to_s); @output_buffer.concat "\n" ^ /Users/alihan/classifieds/app/views/classified/edit.rhtml:13: syntax error, unexpected ''>'' /Users/alihan/classifieds/app/views/classified/edit.rhtml:18: syntax error, unexpected tIDENTIFIER, expecting '')'' <%= form.text_field :email ).to_s); @output_buffer.concat "\n" ^ Extracted source (around line #5): 2: <% form_for @classified do |form| %> 3: <%=form.error_messages%> 4: <p> 5: <%= form.label :title<br/> 6: <%= form.text_field :title %> 7: </p> 8: <p> Trace of template inclusion: app/views/classified/edit.rhtml RAILS_ROOT: /Users/alihan/classifieds thanks... radhames brito wrote:> what i said was based on the fact that i thought your edit action was > named > show so if it was a typo ignore my comment. > > try making this changes and post your routes if it still does not work, > and > what version of rails are you using? > > the edit action should be > > def edit > @classifed = Classified.find(params[:id]) > end > > def update > @classifed = Classified.find(params[:id]) > if @classified.update_attributes(params[:classified]) > flash[:notice] = "updated" > redirect_to @classified > else > render :action => ''edit'' > end > end > > > <h1>Editing Classified: <%= :title -%></h1> > > <% form_for @classified do |form| %> > <%=form.error_messages%> > <p> > <%=form.label :title%><br/> > <%= form.text_field :title %> > </p> > > <p> > <%=form.label :price%><br/> > <%= form.text_field :price %> > </p> > > <p> > <%=form.label :location%><br/> > <%= form.text_field :location %> > </p> > > <p> > <%=form.label :description%><br/> > <%= form.text_area :description %> > </p> > > <p> > <%=form.label :email%><br/> > <%= form.text_field :email %> > </p> > > <%= submit_tag "save changes" %> > <% end %> > > <%= link_to ''Back'', {:action => ''list''} %> > > > in your routes.rb file it should say > > resources classifies, or whatever the plural should be-- 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 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.
Faisal Basha
2010-Sep-26 17:23 UTC
Re: Re: Missing template classified/update.erb in view path app/view
Sorry my bad.....please discard the above post, the error was with the syntax, but now the error I have now is: Showing app/views/classified/edit.rhtml where line #2 raised: Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id 1: <h1>Editing Classified: <%= :title -%></h1> 2: <% form_for @classified do |form| %> 3: <%=form.error_messages%> 4: <p> 5: <%= form.label :title%><br/>> radhames brito wrote: >> what i said was based on the fact that i thought your edit action was >> named >> show so if it was a typo ignore my comment. >> >> try making this changes and post your routes if it still does not work, >> and >> what version of rails are you using? >> >> the edit action should be >> >> def edit >> @classifed = Classified.find(params[:id]) >> end >> >> def update >> @classifed = Classified.find(params[:id]) >> if @classified.update_attributes(params[:classified]) >> flash[:notice] = "updated" >> redirect_to @classified >> else >> render :action => ''edit'' >> end >> end >> >> >> <h1>Editing Classified: <%= :title -%></h1> >> >> <% form_for @classified do |form| %> >> <%=form.error_messages%> >> <p> >> <%=form.label :title%><br/> >> <%= form.text_field :title %> >> </p> >> >> <p> >> <%=form.label :price%><br/> >> <%= form.text_field :price %> >> </p> >> >> <p> >> <%=form.label :location%><br/> >> <%= form.text_field :location %> >> </p> >> >> <p> >> <%=form.label :description%><br/> >> <%= form.text_area :description %> >> </p> >> >> <p> >> <%=form.label :email%><br/> >> <%= form.text_field :email %> >> </p> >> >> <%= submit_tag "save changes" %> >> <% end %> >> >> <%= link_to ''Back'', {:action => ''list''} %> >> >> >> in your routes.rb file it should say >> >> resources classifies, or whatever the plural should be-- 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 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.
Faisal Basha
2010-Sep-26 17:34 UTC
Re: Re: Missing template classified/update.erb in view path app/view
k fixed that.... now the error after I hit submit button after editing: NameError in ClassifiedsController#update uninitialized constant ClassifiedsController Help would be appreciated. Thanks -- 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 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.