jquery is responsible for communication and requesting my particular
methods so it calls appropriate model basing on something like
params[:model], doajaxing method knows how to deal with nested
attributes
so it request from controller some action like
doajaxing_for_createmodel and it looks like:
def doajaxing_for_createmodel
doajaxing("account")
end
and doajaxing itself looks like
def doajaxing(object_name)
if request.xhr?
sended = params[object_name.to_sym]
object_name = object_name.camelize
@process = object_name.constantize
@process = @process.new(sended)
@process.valid?
##some other processing
if @process.errors[current_given]
#process message and field
#some@response is given in json
render :json => @response
end
end
that it work... I wonder if I can use instead of @process.valid?
something else
jquery is responsible for communication and requesting my particular
methods so it calls appropriate model basing on something like
params[:model], doajaxing method knows how to deal with nested
attributes
so it request from controller some action like
doajaxing_for_createmodel and it looks like:
def doajaxing_for_createmodel
doajaxing("account")
end
Because you have "@process.new", the "on_create" validations will be
triggered.
If you are updating an existing record, use
@process = @process.find(...model-id...)
where model-id is usually taken from "params" (params[:id]).
Then assign the new values to @process.
Then the "on_create" validations will not be triggered.
@process.valid?
##some other processing
if @process.errors[current_given]
#process message and field
#some@response is given in json
render :json => @response
end
end
that it work... I wonder if I can use instead of @process.valid?
something else
Hope that helps. I think your "doajaxing" method needs to know about the
two cases, create/update.