hi, i i have a model (Page) and i want to put their multilanguage text
with a polimorphic association model (Lang), because i want to use in
future this model for containing others modules text (example: Category,
Notice, ecc..).



now i make this code on models:

-------------------------
class Page < ActiveRecord::Base
  has_many :langs, :as => :langable
  accepts_nested_attributes_for :langs
end

class Lang < ActiveRecord::Base
  belongs_to :langable, :polymorphic => true
  #other code .....
end
-------------------------


i create form Page with the nested lang fields (i create the new page
with one record on the model Lang, for insert others Langs i use
separated forms):

-------------------------
<% form_for([:admin, @page], :html => {:multipart => true}) do |f| %>
<%= error_messages_for :page %>
<%# ....others fields .... %>
<% f.fields_for :lang do |l| %>
  <%= l.hidden_field :langcode, :value => "en" %>
  <%= l.label :title, "title" %><br />
  <%= l.text_field :title %>
  <%# ....others fields .... %>
<% end %>
<%# ....others fields .... %>
<% end %>
-------------------------


the controller is the same than previously i make the nested modify:

-------------------------
#other code .....

# CREATE PAGE
def create
  @page = Page.new(params[:page])
  respond_to do |format|
    if @page.save
      format.html { redirect_to([:admin, @page]) }
    else
      format.html { render :action => "new" }
    end
  end
end

#other code .....
-------------------------


but on create page i retrieve this error:


unknown attribute: lang


/Users/xxx/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2745:in
`attributes='
/Users/xxx/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2741:in
`each'
/Users/xxx/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2741:in
`attributes='
/Users/xxx/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2439:in
`initialize'
/Users/xxx/Sites/htdocs/rails/my_site/app/controllers/admin/pages_controller.rb:33:in
`new'
/Users/xxx/Sites/htdocs/rails/my_site/app/controllers/admin/pages_controller.rb:33:in
`create'

i have verified the code but all seem ok.
any idea?
-- 
Posted via http://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