# Missing template classified/update.erb in view path app/view

**URL:** <https://www.ruby-forum.com/t/missing-template-classified-update-erb-in-view-path-app-view/195208>\
**Category:** Rails\
**Created:** [September 19, 2010, 8:03pm UTC](https://www.ruby-forum.com/t/missing-template-classified-update-erb-in-view-path-app-view/195208 "2010-09-19T20:03:58Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![binbash-x](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@binbash-x](https://www.ruby-forum.com/u/binbash-x)\
**Post date:** [September 19, 2010, 8:03pm UTC](https://www.ruby-forum.com/t/missing-template-classified-update-erb-in-view-path-app-view/195208/1 "2010-09-19T20:03:58Z")

</div>

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

# Editing Classified: \<%= :title -%\>
\<% form\_for :classified, :url =\> {:action =\> 'update'} do |form| %\> 

Title  
 \<%= form.text\_field :title %\>

price  
 \<%= form.text\_field :price %\>

Location  
 \<%= form.text\_field :location %\>

Description  
 \<%= form.text\_area :description %\>

Email  
 \<%= form.text\_field :email %\>

\<%= submit\_tag “save changes” %\>  
\<% end %\>  
\<%= link\_to ‘Back’, {:action =\> ‘list’} %\>

Help will be appreciated. Thanks

---

<div class="post-metadata">

**Author:** ![binbash-x](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@binbash-x](https://www.ruby-forum.com/u/binbash-x)\
**Post date:** [September 19, 2010, 9:43pm UTC](https://www.ruby-forum.com/t/missing-template-classified-update-erb-in-view-path-app-view/195208/2 "2010-09-19T21:43:49Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![binbash-x](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@binbash-x](https://www.ruby-forum.com/u/binbash-x)\
**Post date:** [September 19, 2010, 11:42pm UTC](https://www.ruby-forum.com/t/missing-template-classified-update-erb-in-view-path-app-view/195208/3 "2010-09-19T23:42:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![binbash-x](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@binbash-x](https://www.ruby-forum.com/u/binbash-x)\
**Post date:** [September 20, 2010, 6:40am UTC](https://www.ruby-forum.com/t/missing-template-classified-update-erb-in-view-path-app-view/195208/4 "2010-09-20T06:40:50Z")

</div>

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

# Editing Classified: \<%= :title -%\>
\<% form\_for :classified, :url =\> {:action =\> 'update'} do |form| %\> 

Title  
 \<%= form.text\_field :title %\>

price  
 \<%= form.text\_field :price %\>

Location  
 \<%= form.text\_field :location %\>

Description  
 \<%= form.text\_area :description %\>

Email  
 \<%= form.text\_field :email %\>

\<%= 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

---

<div class="post-metadata">

**Author:** ![binbash-x](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@binbash-x](https://www.ruby-forum.com/u/binbash-x)\
**Post date:** [September 26, 2010, 7:16pm UTC](https://www.ruby-forum.com/t/missing-template-classified-update-erb-in-view-path-app-view/195208/5 "2010-09-26T19:16:15Z")

</div>

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:

5: \<%= form.label :title  
  
6: \<%= form.text\_field :title %\>  
7:

  
8: 

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
> 
> # Editing Classified: \<%= :title -%\>
> 
> \<% form\_for @classified do |form| %\>  
> \<%=form.error\_messages%\>
> 
> \<%=form.label :title%\>  
> \<%= form.text\_field :title %\>
> 
> \<%=form.label :price%\>  
> \<%= form.text\_field :price %\>
> 
> \<%=form.label :location%\>  
> \<%= form.text\_field :location %\>
> 
> \<%=form.label :description%\>  
> \<%= form.text\_area :description %\>
> 
> \<%=form.label :email%\>  
> \<%= form.text\_field :email %\>
> 
> \<%= 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

---

<div class="post-metadata">

**Author:** ![binbash-x](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@binbash-x](https://www.ruby-forum.com/u/binbash-x)\
**Post date:** [September 20, 2010, 7:08am UTC](https://www.ruby-forum.com/t/missing-template-classified-update-erb-in-view-path-app-view/195208/6 "2010-09-20T07:08:33Z")

</div>

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

# Editing Classified: \<%= :title -%\>

\<% form\_for @classified do |form| %\>  
\<%=form.error\_messages%\>

\<%=form.label :title%\>  
 \<%= form.text\_field :title %\>

\<%=form.label :price%\>  
 \<%= form.text\_field :price %\>

\<%=form.label :location%\>  
 \<%= form.text\_field :location %\>

\<%=form.label :description%\>  
 \<%= form.text\_area :description %\>

\<%=form.label :email%\>  
 \<%= form.text\_field :email %\>

\<%= 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

---

<div class="post-metadata">

**Author:** ![binbash-x](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@binbash-x](https://www.ruby-forum.com/u/binbash-x)\
**Post date:** [September 26, 2010, 7:23pm UTC](https://www.ruby-forum.com/t/missing-template-classified-update-erb-in-view-path-app-view/195208/7 "2010-09-26T19:23:05Z")

</div>

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:

# Editing Classified: \<%= :title -%\>
  
2: \<% form\_for @classified do |form| %\>  
3: \<%=form.error\_messages%\>  
4: 

5: \<%= form.label :title%\>

> 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
> > 
> > # Editing Classified: \<%= :title -%\>
> > 
> > \<% form\_for @classified do |form| %\>  
> > \<%=form.error\_messages%\>
> > 
> > \<%=form.label :title%\>  
> > \<%= form.text\_field :title %\>
> > 
> > \<%=form.label :price%\>  
> > \<%= form.text\_field :price %\>
> > 
> > \<%=form.label :location%\>  
> > \<%= form.text\_field :location %\>
> > 
> > \<%=form.label :description%\>  
> > \<%= form.text\_area :description %\>
> > 
> > \<%=form.label :email%\>  
> > \<%= form.text\_field :email %\>
> > 
> > \<%= 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

---

<div class="post-metadata">

**Author:** ![binbash-x](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@binbash-x](https://www.ruby-forum.com/u/binbash-x)\
**Post date:** [September 26, 2010, 7:34pm UTC](https://www.ruby-forum.com/t/missing-template-classified-update-erb-in-view-path-app-view/195208/8 "2010-09-26T19:34:38Z")

</div>

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
