Hi, I have a User model with a HABTM relation to a Role model and vice versa. So There''s a roles_users table that references :user and :role. I''m using formtastic, and in the user.edit.html.erb I have a line that outputs the roles as a multi-select list box. But the box is not showing the roles that have been assigned to the users. Another problem is that if I select a few roles and press the update button, the roles are not being asssigned. I have to manually assign roles by accessing the database. Isn''t this stuff supposed to happen automatically when you call @user.update_attributes(params[:user]) in the user_controller ? Thanks in advance. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi How do u create form here? Sijo -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ali Akhtarzada
2010-Jun-05 21:44 UTC
Re: Re: How do you update HABTM relationships or create.
Hi, just like the following: <% semantic_form_for @user do |f| %> <% f.inputs do %> <%= f.input :email %> <%= f.input :first_name %> <%= f.input :last_name %> <%= f.input :roles %> <% end %> <%= f.buttons %> <% end %> On Sun, Jun 6, 2010 at 5:31 AM, Sijo k g <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi > > How do u create form here? > > Sijo > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ali Akhtarzada
2010-Jun-05 21:58 UTC
Re: Re: How do you update HABTM relationships or create.
Ok I found the problem, I had an attr_accessor :role_ids in my User model which was throwing things off. Everything worked after I removed it. On Sun, Jun 6, 2010 at 9:44 AM, Ali Akhtarzada <ali.akhtarzada-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> Hi, just like the following: > > <% semantic_form_for @user do |f| %> > <% f.inputs do %> > <%= f.input :email %> > <%= f.input :first_name %> > <%= f.input :last_name %> > <%= f.input :roles %> > <% end %> > <%= f.buttons %> > <% end %> > > > On Sun, Jun 6, 2010 at 5:31 AM, Sijo k g <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > >> Hi >> >> How do u create form here? >> >> Sijo >> -- >> 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> >-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
bramu.ss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2010-Jun-07 04:06 UTC
Re: How do you update HABTM relationships or create.
I am very new to Rails and I am more or less only 6 months to 1 year kid in Rails... I just wondering with your code.. I really dont see what is "semantic_form_for " and f.buttons?? Is it view helper that you have written or any plugin which overrides the default form_for construct?? This would be very helpful to me in writing the more maintainable Rails code... On Jun 6, 2:58 am, Ali Akhtarzada <ali.akhtarz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Ok I found the problem, I had an attr_accessor :role_ids in my User model > which was throwing things off. Everything worked after I removed it. > > On Sun, Jun 6, 2010 at 9:44 AM, Ali Akhtarzada <ali.akhtarz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > > > > > Hi, just like the following: > > > <% semantic_form_for @user do |f| %> > > <% f.inputs do %> > > <%= f.input :email %> > > <%= f.input :first_name %> > > <%= f.input :last_name %> > > <%= f.input :roles %> > > <% end %> > > <%= f.buttons %> > > <% end %> > > > On Sun, Jun 6, 2010 at 5:31 AM, Sijo k g <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > >> Hi > > >> How do u create form here? > > >> Sijo > >> -- > >> Posted viahttp://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org. > >> To unsubscribe from this group, send email to > >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscrib e@googlegroups.com> > >> . > >> For more options, visit this group at > >>http://groups.google.com/group/rubyonrails-talk?hl=en.-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Jun-07 04:21 UTC
Re: How do you update HABTM relationships or create.
bramu.ss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> I am very new to Rails and I am more or less only 6 months to 1 year > kid in Rails... > > I just wondering with your code.. I really dont see what is > "semantic_form_for " and f.buttons?? Is it view helper that you have > written or any plugin which overrides the default form_for construct?? > This would be very helpful to me in writing the more maintainable > Rails code...He said he was using Formtastic. That''s probably where those methods come from. But don''t take my word for it. Google is your friend in this case. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ali Akhtarzada
2010-Jun-08 00:15 UTC
Re: Re: How do you update HABTM relationships or create.
Formtastic indeed. On Mon, Jun 7, 2010 at 4:21 PM, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> bramu.ss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > I am very new to Rails and I am more or less only 6 months to 1 year > > kid in Rails... > > > > I just wondering with your code.. I really dont see what is > > "semantic_form_for " and f.buttons?? Is it view helper that you have > > written or any plugin which overrides the default form_for construct?? > > This would be very helpful to me in writing the more maintainable > > Rails code... > > He said he was using Formtastic. That''s probably where those methods > come from. But don''t take my word for it. Google is your friend in > this case. > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.