here is the full content of category_controller.rb
class CategoryController < ApplicationController
def index
“List all categories”
list
render:action=>‘list’
end
#— List–
def list
# @categories=Category.find_recent_categories
@categories=Category.find_all_categories
end #---- Show —
def show
# @category=Category.find(params[:category_id])
@category=Category.find(params[:category_id])
end
“you have an unexpected nil error”
Regardless of the HTML comments in your view file, the Ruby inside the
<% %> tags will get evaluated - if it’s invalid it will error (as it
is); if it’s valid, you’d end up with a commented-out html select
tag…
if you just want it commented, comment the Ruby:
If you want a select tag, read the documents on collection_select and
ensure @subjects is correctly populated with objects (or is an empty
array).
hi,
you can not just comment these lines because the second line having
Ruby code inside<%= …%>
for this line you may use # like as written below.
<%#= collection_select(:book,:subject_id,@subjects,:id,:name) %>
Now it is commented out. And code will not read this line…
to <%#= collection_select(:book,:subject_id,@subjects,:id,:name) %>
thanks for all . thanks rajeev and hassan and michael.
thanks MicahelPavling, santosh, axelsef and ssmithstone.
special thanks to michael, santosh and ssmithstone, I commented those
two lines as per your explanation as ruby evaluates them first before
generating the html and it works fine.
thanks again!
-radha
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.