An empty (but working) show method on a forest-created controller?

How does this show method in the controller class generated using rails generate scaffold xxx empty / not contain code? Where is the code to display individual entries via a URL, for example. /my_rails_app:3000/xxx/1 saved?

The method should at least look like this:

 class ProductController # GET /students/1 # GET /students/1.json def show @item = Product.find(params[:id]) render @item end end 

but instead, it is completely empty:

 class ProductController # GET /students/1 # GET /students/1.json def show end end 
+7
ruby-on-rails ruby-on-rails-4
source share
1 answer

If you use rails 4, then you should have some method before you do the magic for you, please check the appropriate controller.

It should be like before_action :set_product, :only => [:show, :edit, :update, :destroy]

+11
source share

All Articles