I am having problems with my edit form. For some reason, my selection assistant is not working properly in the editing action. For some reason, it seems that the option: prompt => true is being ignored and the message "Please select" is not displayed. But only in the edit action does the new action work fine.
fragment from the form:
f.select :category_id, @categories, {:prompt => true}
edit action
def edit
@page = Page.find(params[:id])
@categories = Category.where(:cat_type=>"page").map { |c| [t("category.#{c.slug}",:default=>"#{c.name}"), c.id] }
end
new action
def new
@page = Page.new
@categories = Category.where(:cat_type=>"page").map { |c| [t("category.#{c.slug}",:default=>"#{c.name}"), c.id] }
respond_to do |format|
format.html
format.json { render json: @page }
end
end
Any idea?
source
share