Skip to content

Instantly share code, notes, and snippets.

@ysinc88
Last active August 29, 2015 14:16
Show Gist options
  • Save ysinc88/bae416815491021ddf45 to your computer and use it in GitHub Desktop.
Save ysinc88/bae416815491021ddf45 to your computer and use it in GitHub Desktop.
Simple show not working
class Product < ActiveRecord::Base
belongs_to :product_category
has_many :product_images
has_many :led_configurations
has_many :leds, through: :led_configurations
include FriendlyId
friendly_id :name, :use => [:slugged]
end
class Admin::ProductsController < Admin::BaseAdminController
def show
@products = Product.all #this works
@product = Product.friendly.find(params[:id]) #this doesnt > returning nil
end
end
http://example.com/admin/products/600w-2wl
<% @product.each do |p| %>
<tr>
<td><%= p.name %></td>
</tr>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment