Sunday, September 26, 2010

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