Model is passed by @model variable with nested attributes so it is
like:

@model = model.new
@model.build_another

at form it is looped through like

- form_for @account, :url => { :action => @given_action , :controller
=> 'admin'} do |f|
- f.fields_for :company do |o|
        %label{:for => "company|name"}=
Company.human_attribute_name(:name)
        = o.text_field :name, :named => "company|name"
        - o.fields_for :city do |x|
          %label{:for => "company|city|name"}=
City.human_attribute_name(:name)
          = x.text_field :name, :named => "company|city|name"


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


On 22 Mar, 19:57, Stephan Wehner <[email protected]> wrote:
> Piotr MÄ…sior wrote:
> > So painful, I was wondering is there any dry_save or something like
> > this ?
>
> How do you populate your @model?
>
> Stephan
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to