Sunday, September 19, 2010

[Rails] 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@googlegroups.com.
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate