Re: Re: Unitialized constant controller

Faisal Basha
Tue, 28 Sep 2010 14:19:46 -0000

Colin Law wrote:
> On 28 September 2010 10:05, Faisal Basha
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:
>
> Please don''t top post, it makes it difficult to follow the thread
>
>> hi, Yes the below code is what I have i.e update method in
>
> Presumably the ''yes'' is in response to Fred''s
question: ''Does that
> controller exist (and in the right place) ?''
>
>> Classifieds_controller.rb....
>
> It should be classifieds_controller.rb (lower case) though I do not
> know whether that is the root of the problem.
>
> Colin

Cool, Now I understand....I think....

Classifieds_controller.rb....

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

Edit.rhtml

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''} %>