Ruby on Rails Tuesday, October 30, 2012

Il 30/10/12 11:58, Sreekesh O. ha scritto:
> The controller code for edit view:
> ******************************************
>
> def edit
> @<%= file_name %> = <%= class_name %>.find(params[:id])
> end
>

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>

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment