**EDIT:** Running the command rake db:seed fixed the problem for me.
I'm learning Ruby on Rails for the first time, and have been trying to setup my laptop to continue where I was on my desktop with my project. I had some issues yesterday of my laptop running Ruby through rvm and desktop running through rbenv, so I fixed that. Now however, I am getting the following error on my laptop but everything works fine on my laptop.
ActionController::UrlGenerationError in Categories#index
No route matches {:action=>"show", :controller=>"categories", :id=>nil} missing required keys: [:id]
<%= link_to 'housing', category_path(@housing) %> | ||||||
---|---|---|---|---|---|---|
I believe it should work. If I understand the code right, I am linking to my housing category via the category path by passing in the @housing parameter and the @housing should have the id as per my categories_controller below. Like I said, this works on my desktop! It links where I want it to, but here it doesn't. Code as follows thanks in advance for any help. output from my rake routes command with the route I am trying to use... category GET /categories/:id(.:format) categories#show index.html.erb
routes.rb #Creates CRUD actions for categories #Performs the search #Set homepage to index of categories #Matches the pages help action to a get request categories_controller.rb class CategoriesController < ApplicationController #The index page of our categories controller def index @categories = Category.all @housing = @categories[0] @roommates = @categories[1] @forsale = @categories[2] end def show @listings = Listing.where(category_id: params[:id]) end end 1 thought on “Routes/Link_to working on one computer but not the other.”Leave a Comment |
How did you move your code?