Hiiii,
I have created one migration..
class TagContentMasterJoin < ActiveRecord::Migration
def self.up
create_table 'content_masters_tags' do |t|
t.column 'tag_id', :integer
t.column 'content_master_id', :integer
t.timestamps
end
end
def self.down
drop_table 'content_masters_tags'
end
end
for joining two tables
and in content_master view new want to save associated tag in the
above table for that i have written this code in content_master view
new
<% for tag in Tag.find(:all) %>
<div>
<%=check_box_tag "content_master[tag_id][]", tag.id,
@content_master.tags.include?(tag) %>
<%= tag.name %>
</div>
<% end %>
and in my create function of content master controller following code
is present ..
def create
@content_master = ContentMaster.new
@content_master.tags=params[:content_master][:tag_id]
respond_to do |format|
if @content_master.save
#save images
and some code here
but this all giving me this error
ActiveRecord::AssociationTypeMismatch in Content
mastersController#create
Tag(#46439460) expected, got String(#21132310)
RAILS_ROOT: D:/TestingGeek/trunk/Site
Application Trace | Framework Trace | Full Trace
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
associations/association_proxy.rb:262:in `raise_on_type_mismatch'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
associations/association_collection.rb:320:in `replace'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
associations/association_collection.rb:320:in `each'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
associations/association_collection.rb:320:in `replace'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
associations.rb:1325:in `tags='
D:/TestingGeek/trunk/Site/app/controllers/
content_masters_controller.rb:64:in `create'
and in my model code is
has_and_belongs_to_many :content_masters
has_and_belongs_to_many :tags
i have give as respective model..
please help this is urgent..
thanks
rahul..
--
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.