Note that there are some explanatory texts on larger screens.

plurals
  1. PORouting Error "No route matches" 'new' path
    primarykey
    data
    text
    <p>I have a <code>User</code> model and a <code>Storefront</code> model.</p> <h3>For some reason, when I try to go to /storefronts/new I get this error: </h3> <blockquote> <p>Routing Error No route matches {:action=>"edit", :controller=>"storefronts", :id=># Storefront id: nil, name: nil, user_id: 4, created_at: nil, updated_at: nil, description: nil, location: nil>}</p> </blockquote> <p>Been at it for 3 hours trying to figure this out. It was working yesterday.. Why does it say <strong>:action=>"edit"</strong> when its the 'new' action?</p> <p>Here's my code:</p> <pre><code>class Storefront &lt; ActiveRecord::Base attr_accessible :name, :location, :description belongs_to :user end class User &lt; ActiveRecord::Base attr_accessible :name, :email, :password, :password_confirmation has_secure_password has_one :storefront end class StorefrontsController &lt; ApplicationController before_filter :check_auth, only: [:new, :edit, :update] def index @storefronts = Storefront.all end def new @storefront = current_user.build_storefront end def create @storefront = current_user.build_storefront(params[:storefront]) if @storefront.save redirect_to edit_storefront_path(@storefront) else render 'new' end end def show @storefront = Storefront.find(params[:id]) end def edit @storefront = Storefront.find(params[:id]) end def update @storefront = Storefront.find(params[:id]) if @storefront.update_attributes(params[:storefront]) redirect_to @storefront else render 'edit' end end end Pbf::Application.routes.draw do resources :sessions, :only =&gt; [:new, :create, :destroy] resources :users resources :storefronts root :to =&gt; 'storefronts#index' match '/signup', to: 'users#new' match '/login', to: 'sessions#new' match '/logout', to: 'sessions#destroy' end </code></pre> <p>Link I'm using <strong>(Here's the issue)</strong>:</p> <pre><code> &lt;% if current_user.storefront %&gt; &lt;%= link_to "Manage Storefront", edit_storefront_path(current_user.storefront) %&gt; &lt;% else %&gt; &lt;%= link_to "Open Storefront!", openstore_path %&gt; &lt;% end %&gt; </code></pre> <p>Thanks in advance!</p> <p>EDIT: My <code>rake routes</code></p> <blockquote> <pre><code> sessions POST /sessions(.:format) sessions#create new_session GET /sessions/new(.:format) sessions#new session DELETE /sessions/:id(.:format) sessions#destroy users GET /users(.:format) users#index POST /users(.:format) users#create new_user GET /users/new(.:format) users#new edit_user GET /users/:id/edit(.:format) users#edit user GET /users/:id(.:format) users#show PUT /users/:id(.:format) users#update DELETE /users/:id(.:format) users#destroy storefronts GET /storefronts(.:format) storefronts#index POST /storefronts(.:format) storefronts#create new_storefront GET /storefronts/new(.:format) storefronts#new edit_storefront GET /storefronts/:id/edit(.:format) storefronts#edit storefront GET /storefronts/:id(.:format) storefronts#show PUT /storefronts/:id(.:format) storefronts#update DELETE /storefronts/:id(.:format) storefronts#destroy </code></pre> </blockquote>
    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