I have controller for representing join of Project and User,
joinProjectsUser.
I have added other configuration for like excluding show and search
action in this controller.


When I added following action_link
config.action_links.add 'create', :label => 'Create A New
User',:parameters =>{:controller=>'user'},:page=>true

I get link as expected which take me to new page with form to create
new user. But I get following error message, when I try to save this
new record.
Malformed constraint `Userr#project_id'. If it's a legitimate column,
and you are using a nested scaffold, please specify or double-check
the reverse association name.

ActiveScaffold is passing project_id of Project, which had link for
creation of new User, as a constraint. To satisfy this constraint, it
is searching for column corresponding to project_id in user table.
Since user table does not have any column called project_id, creation
of user fails.

I have added method called 'project_id=' in UsersController, This
method gets called during constraint check with project_id passed to
it as parameter.

Thanks a lot for your help.


On Feb 14, 6:07 am, "Sergio Cambra .:: entreCables S.L. ::."
<[email protected]> wrote:
> On Viernes, 11 de Febrero de 2011 00:40:06 sp8786 escribió:
>
> > I have two tables Project and Users, which have many-to-many
> > relationship.
> > I am displaying list of projects with option to edit members of
> > projects.
> > Currently I am able to support only adding existing users to project.
> > But I want to add support for 'adding new users' as a link when
> > displaying each project.
>
> > config.action_links.add 'create', :label => 'Create A New
> > User',:parameters =>{:controller=>'user'},:page=>true
>
> Which controller do you add that line in?
>
>
>
>
>
>
>
>
>
>
>
> > But upon clicking this link, project_id for which link was clicked is
> > passed as constraint. Since user does not have any project_id column,
> > I get following error
>
> > Malformed constraint `Userr#project_id'. If it's a legitimate column,
> > and you are using a nested scaffold, please specify or double-check
> > the reverse association name.
>
> > Here is my Model
> > class User < ActiveRecord::Base
> > has_many :join_user_project,
>
> >            :foreign_key => 'user_id'
>
> >   has_many :projects,
>
> >            :through => :join_user_project
>
> > end
>
> > class Page < ActiveRecord::Base
> > has_many :join_user_project,
>
> >            :foreign_key => 'project_id'
>
> >   has_many :users,
>
> >            :through => :join_user_project
>
> > end
>
> --
> Sergio Cambra .:: entreCables S.L. ::.
> Mariana Pineda 23, 50.018 Zaragoza
> T) 902 021 404 F) 976 52 98 07 E) [email protected]

-- 
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.

Reply via email to