Sorry I didn't work much on nested and 'craete table'. I directly create 
tables in MySQL.

However I see that you have 'roles_users.user_id' instead of 
'roles.user_id' in the WHERE clause of the SQL.

andrea wrote:
> I'm running ActiveScaffold 1.2RC1 (from 
> git://github.com/activescaffold/active_scaffold.git)
> and Rails 2.1, with MySQL 5.0.51 as the database. I'm having a problem
> select a nested HABTM association; when click on the respective
> column, i have :
>
> ----------------------------------------------------------
> ActiveRecord::StatementInvalid in RolesController#table
>
> Mysql::Error: Unknown column 'roles_users.user_id' in 'where clause':
> SELECT DISTINCT `roles`.id FROM `roles`     WHERE (roles_users.user_id
> = '1')  ORDER BY roles.`id` ASC LIMIT 0, 15
> Missing JOIN with users table ?? I have the same error on the roles
> table with nested users column.
> ----------------------------------------------------------
>
> class Role < ActiveRecord::Base
>   has_and_belongs_to_many :users
> end
>
> class User < ActiveRecord::Base
>   has_and_belongs_to_many :roles
> end
>
> class RolesController < ApplicationController
>   active_scaffold :role do |config|
>     config.columns = [:name, :users]
>   end
> end
>
> class UsersController < ApplicationController
>   active_scaffold :user do |config|
>     config.columns = [:login, :roles]
>   end
> end
>
> class CreateUsers < ActiveRecord::Migration
>   def self.up
>     create_table :users do |t|
>       t.string :login
>       t.timestamps
>     end
>     create_table :roles_users do |t|
>       t.integer :user_id, :role_id, :null => false
>       t.timestamps
>     end
>   end
>
>   def self.down
>     drop_table :users
>   end
> end
>
> class CreateRoles < ActiveRecord::Migration
>   def self.up
>     create_table :roles do |t|
>       t.string :name
>       t.timestamps
>     end
>   end
> end
>
>
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---

  • Pr... andrea
    • ... Sri Sri
      • ... andrea
        • ... Matt Culbreth
    • ... Peter Liu
      • ... vikano
        • ... Sergio Cambra .:: entreCables - Symbol Servicios Informáticos S.L. ::.

Reply via email to