Note that there are some explanatory texts on larger screens.

plurals
  1. PONo route matches when trying to edit
    primarykey
    data
    text
    <p>Here's the scoop: I've created a test app that allows users to create ideas and then add "bubbles" to these ideas. Currently, a bubble is just text. I've successfully linked bubbles to ideas. Furthermore, when a user goes to view an idea it lists all of the bubbles attached to that idea. The user can even delete the bubble for a given idea. </p> <p>My problem lies in editing bubbles. When a user views an idea, he sees the idea's content as well as any bubbles for that idea. As a result, I've set all my bubble controls (editing and deleting) inside the ideas "show" view. My code for editing a bubble for an idea is <code>&lt;%= link_to 'Edit Bubble', edit_idea_bubble_path %&gt;</code>. I ran <code>rake routes</code> to find the correct path for editing bubbles and that is what was listed. </p> <p>Here's my error: <code>No route matches {:action=&gt;"edit", :controller=&gt;"bubbles"}</code></p> <p>In my bubbles controller I have:</p> <pre><code>def edit @idea = Idea.find(params[:idea_id]) @bubble = @idea.bubbles.find(params[:id]) end def update @idea = Idea.find(params[:idea_id]) @bubble = @idea.bubbles.find(params[:id]) respond_to do |format| if @bubble.update_attributes(params[:bubble]) format.html { redirect_to(@bubble, :notice =&gt; 'Bubble was successfully updated.') } format.xml { head :ok } else format.html { render :action =&gt; "Edit" } format.xml { render :xml =&gt; @bubble.errors, :status =&gt; :unprocessable_entity } end end end </code></pre> <p>To go a step further, I have the following in my <code>routes.rb</code> file</p> <pre><code>resources :ideas do resources :bubbles end </code></pre> <p>So far everything seems to function except when I try to edit a bubble. </p> <p>I'd love some guidance.</p> <p>Thanks!</p> <p>Here's my <code>show.html.erb</code> file for Ideas:</p> <pre><code>&lt;h2&gt;Bubbles&lt;/h2&gt; &lt;% @idea.bubbles.each do |bubble| %&gt; &lt;p&gt; &lt;b&gt;Bubble:&lt;/b&gt; &lt;%= bubble.description %&gt; &lt;/p&gt; &lt;p&gt; &lt;%= link_to 'Edit Bubble', edit_idea_bubble_path (@idea) %&gt; &lt;/p&gt; &lt;tb /&gt; &lt;p&gt; &lt;%= link_to 'Delete Bubble', [bubble.idea, bubble], :confirm =&gt; 'Are you sure you want to delete this bubble?', :method =&gt; :delete %&gt; &lt;/p&gt; &lt;% end %&gt; &lt;h2&gt;Add a bubble:&lt;/h2&gt; &lt;%= form_for([@idea, @idea.bubbles.build]) do |f| %&gt; &lt;div class="field"&gt; &lt;%= f.label :description %&gt;&lt;br /&gt; &lt;%= f.text_area :description %&gt; &lt;/div&gt; &lt;div class="actions"&gt; &lt;%= f.submit %&gt; &lt;/div&gt;&lt;% end %&gt; </code></pre> <p>Following <code>edit_idea_bubble_path (@idea)</code>, here is the <code>edit.html.erb</code> file for Bubbles:</p> <pre><code>&lt;%= render 'form' %&gt; &lt;%= link_to 'Back to Ideas', ideas_path %&gt; </code></pre> <p>And finally, my <code>_form.html.erb</code> file for Bubbles: this is where the problem lies, I believe</p> <pre><code>&lt;% form_for([@idea, @idea.bubbles.build]) do |f| %&gt; &lt;%= f.error_messages %&gt; &lt;div class="field"&gt; &lt;%= f.label :description %&gt;&lt;br /&gt; &lt;%= f.text_area :description %&gt; &lt;/div&gt; &lt;div class="actions"&gt; &lt;%= f.submit %&gt; &lt;/div&gt; &lt;% end %&gt; </code></pre>
    singulars
    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.
    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