Error while customizing view template in Ruby on Rails

I was trying to create custom view pages in ROR as seen in

then i got some errors

Share your controller code where you are rendering this view.

The controller code for edit view:

Where the file_name and class_name are declared? I don’t see them declared inside the edit function.

You put ERB, which must be in the views, in the controller. This is how the controller should be (pure ruby code):

def edit    @file_name = class_name.find(params[:id]) end

and in the view (edit.html.erb) you can show @file_name in this way:

<div>    <%= @file_name.some_attribute %> </div>

Where the file_name and class_name are declared? I don’t see them declared inside the edit function.

The controller code for edit view:


def edit

@<%= file_name %> = <%= class_name %>.find(params[:id])

end

you are using erb code inside the controller. i don’t get why you want to do this or if it’s even

possible to do it like this. start with the basic tutorials first before you go ahead with what you’re

trying to do.

These are files in rails installation folder the scaffold-generator template. These are defined default by rails

path of files in linux:

usr/lib/ruby/gems/1.8/gems/rails 2.3.5/lib/rails-generator/generator/components/scaffold/template

Jim ruther Nill wrote in post #1081968: