I did try that. For some reason update action does not see
params[:in_progress] == "true" as true. It is 'true' in params hash
though. Any other thoughts? Been trying to figure this out all week.
In view:
<%= f.submit "Add image/video", :id=> 'add_image_commit' %>
jQuery sets hidden field "in_progress" to true:
$("#add_image_commit").on "click", (event) -> # User clicks "Add image"
button.
$("#in_progress").val("true")
hidden field IS set to true.
In controller:
def update
@question = Question.find(params[:id])
if params[:in_progress] == "true"
@question.attributes = params[:question]
if @question.save(:validate => false)
redirect_to gallery_path(session[:minisection_id]), id:
"image_gallery"
end
else.....
Still learning rails and have a basic question. Can I pass any variable
thru the params hash to an action?
You can do that the same way you would do it in HTML, use a hidden form
field. Rails has a helper for that:
I did try that. For some reason update action does not see
params[:in_progress] == "true" as true. It is 'true' in params hash
though. Any other thoughts? Been trying to figure this out all week.
In view:
<%= f.submit "Add image/video", :id=> 'add_image_commit' %>
jQuery sets hidden field "in_progress" to true:
$("#add_image_commit").on "click", (event) ->
$("#in_progress").val("true")
Hidden field IS set to true.
In controller:
def update
@question = Question.find(params[:id])
if params[:in_progress] == "true"
@question.attributes = params[:question]
if @question.save(:validate => false)
redirect_to gallery_path(session[:minisection_id]), id:
"image_gallery"
end
else.....
Still learning rails and have a basic question. Can I pass any variable
thru the params hash to an action?
You can do that the same way you would do it in HTML, use a hidden form
field. Rails has a helper for that:
I did try that. For some reason update action does not see
params[:in_progress] == "true" as true. It is 'true' in params hash
though. Any other thoughts? Been trying to figure this out all week.
In view:
<%= f.submit "Add image/video", :id=> 'add_image_commit' %>
jQuery sets hidden field "in_progress" to true:
$("#add_image_commit").on "click", (event) ->
$("#in_progress").val("true")
Hidden field IS set to true.
In controller:
def update
@question = Question.find(params[:id])
if params[:in_progress] == "true"
@question.attributes = params[:question]
if @question.save(:validate => false)
redirect_to gallery_path(session[:minisection_id]), id:
"image_gallery"
end
else.....