Hi there,
it's an afternoon that i'm destroying my head on this, and i've decided
to ask to you all .
I've got to do some check box lists for a modified substruct version i'm
doing, right now, i'm interested to insert a list of categories of
interests into a customer sheet
i'm using the substruct plugin version, wich stays in the plugin/vendor
version.
the category.rb stays in the myapp/app/models , while the order_user.rb
stays in myapp/vendor/plugins/substruct/app/models .
this is my models
class Category < ActiveRecord::Base
has_and_belongs_to_many :order_users
end
class OrderUser < ActiveRecord::Base
include CheckboxSelectable
has_and_belongs_to_many :categories
#many other things down below
end
this are my controller
def updateCust
@customer = OrderUser.find(params[:id])
@customer.update_attributes(params[:customer])
@customer.update_check_list(params, 'Category')
if @customer.save
flash[:notice] = 'Customer was successfully updated.'
redirect_to :action => 'customers'
else
flash[:notice] = 'Something went wrong,please review your
data'
redirect_to :action => 'customers'
end
end
and the view
<%= checkbox_select('customer', 'categories', @categories, 'name') %>
As you can see, i'm using the Checkbox select rails plugin (
http://scoop.cheerfactory.co.uk/2007/11/05/checkbox-select-rails-plugin/
).
I've already tried the version in the railscast
(http://railscasts.com/episodes/17) but in both cases, the first time i
try to load the page, i get this error:
substruct_development.categories_order_users' doesn't exist: SELECT
`categories`.id FROM `categories` INNER JOIN `categories_order_users`
ON `categories`.id = `categories_order_users`.category_id
, so i reload and all goes fine!ad the boxes too, they appears!
but if i try to check a box and then to save a record, i get this error:
ActiveRecord::AssociationTypeMismatch in
Admin/usersController#updateCust
Category(#18224400) expected, got Category(#18557480)
or something similar, only numbers change!
Now, AssociationTypeMismatch is when you want to cope wrong types of
data together, but this is not the case :(
what i've to do? please help me!
--
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
-~----------~----~----~----~------~----~------~--~---