Note that there are some explanatory texts on larger screens.

plurals
  1. PORouting error while using partial form in rails 3
    primarykey
    data
    text
    <p>does anyone know how to use a form partial to create and update data about an object? My update method seems to work, but I can't create a new object. Every time I clink on the 'Add new ad' I get this error:[ActionController:Routing Error in Classified#new No route matches {:controller=>classified}]. Here is the code for the partial form: The error points to the first line:</p> <pre><code>&lt;%= form_for(@classified) do |f| %&gt; &lt;p&gt; &lt;%= f.label :title %&gt;&lt;br/&gt; &lt;%= f.text_field :title %&gt; &lt;/p&gt; &lt;p&gt; &lt;%= f.label :price %&gt;&lt;br/&gt; &lt;%= f.text_field :price %&gt; &lt;/p&gt; &lt;p&gt; &lt;%= f.label :location %&gt;&lt;br/&gt; &lt;%= f.text_field :location %&gt; &lt;/p&gt; &lt;%= f.label :description %&gt;&lt;br/&gt; &lt;%= f.text_area :description %&gt; &lt;%= f.label :email %&gt;&lt;br/&gt; &lt;%= f.text_field :email %&gt; &lt;%= f.submit %&gt; &lt;% end %&gt; &lt;%= link_to 'Back', {:action =&gt; 'list'} %&gt; </code></pre> <p>Here are my methods for new, edit and update in the Classified controller class:</p> <pre><code>def new @classified=Classified.new end </code></pre> <p>Here is the 'def create' method:</p> <pre><code>def create @classified = Classified.new(params[:classified]) if @classified.save redirect_to :action =&gt; 'list' else render :action =&gt; 'new' end end </code></pre> <p>I suspect the problem is in my config/routes.rb. I already have this line:</p> <pre><code>resources :classified </code></pre> <p>I have also put:</p> <pre><code>root :to =&gt; "Classified#list" root :to =&gt; "Classified#new" root :to =&gt; "Classified#show" root :to =&gt; "Classified#edit" root :to =&gt; "Classified#form </code></pre> <p>Could the problem be with the routes.rb file. And how comes it works with the update method and not the new method? Please help. I have tried all possible tricks to no avail. I will be so glad. Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload