twiddle
unread,Jun 14, 2013, 6:41:33 PM6/14/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rails...@googlegroups.com
I'm pulling my hair out with this. I've been googling this problem for nearly two hours. I'm trying to get the product view to have a dropdown which lets me select a tag. Instead it just lists the tags without letting me edit them. What am I doing wrong? I have:
product.rb
class Product < ActiveRecord::Base
has_and_belongs_to_many :tags
attr_accessible :available, :description, :name, :price, :tag_id, :id
accepts_nested_attributes_for :tags, allow_destroy: true
end
tag.rb
class Tag < ActiveRecord::Base
has_and_belongs_to_many :products
attr_accessible :name, :id, :product_id
accepts_nested_attributes_for :products, allow_destroy: true
end
schema.rb
ActiveRecord::Schema.define(:version => 20130614182226) do
create_table "products", :force => true do |t|
t.string "name"
t.string "description"
t.boolean "available"
t.integer "price"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "products_tags", :id => false, :force => true do |t|
t.integer "product_id"
t.integer "tag_id"
end
create_table "tags", :force => true do |t|
t.string "name"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
end
rails_admin.rb
RailsAdmin.config do |config|
config.model Product do
edit do
field :tags, :has_and_belongs_to_many_association
end
end
end