class User < ActiveRecord::Base has_many :correlations has_many :roles, :through => :correlations has_many :skills, :through => :correlations attr_accessible :email, :password, :password_confirmation, :remember_me, :role_ids, :skill_ids, :username, :first_name, :last_name, :address, :city, :state , :country, :phone_number, :photo,:fullname, :shortbio, :weburl def role?(role) return !!self.roles.find_by_name(role.to_s.camelize) end def skill?(skill) return !!self.skills.find_by_name(skill.to_s.camelize) end end class Correlation < ActiveRecord::Base belongs_to :role belongs_to :skill belongs_to :user end class Skill < ActiveRecord::Base has_many :correlations has_many :roles, :through => :correlations has_many :users, :through => :correlations end class Role < ActiveRecord::Base has_many :correlations has_many :skills, :through => :correlations has_many :users, :through => :correlations end module ArticlesHelper def skill_list skills_ids = current_user.skill_ids skills_ids.delete_if {|x| x == nil} skills = Skill.find(skills_ids) return skills end end if working fine but on heroku console @user.skill_ids NoMethodError: undefined method `skill_ids'' for #<ActiveRecord::Relation:0x00000005515b58> @user.role_ids NoMethodError: undefined method `skill_ids'' for #<ActiveRecord::Relation:0x00000005515b58> Any idea? Pleaase help ccdd -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/cT_VsW2C9RoJ. 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.
Your problem is here:> @user.skill_ids > NoMethodError: undefined method `skill_ids'' for > #<ActiveRecord::Relation:0x00000005515b58> > @user.role_ids > NoMethodError: undefined method `skill_ids'' for > #<ActiveRecord::Relation:0x00000005515b58>Try @user.skills.all and @user.roles.all. Of you really DO want just the ids (seriously ask yourself why), then @user.skills.all.collect(&:id) and @user.roles.all.collect(&:id) -- 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.
not working On Thu, Jun 16, 2011 at 1:20 PM, askegg <andrew.skegg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Your problem is here: > > > @user.skill_ids > > NoMethodError: undefined method `skill_ids'' for > > #<ActiveRecord::Relation:0x00000005515b58> > > @user.role_ids > > NoMethodError: undefined method `skill_ids'' for > > #<ActiveRecord::Relation:0x00000005515b58> > > Try @user.skills.all and @user.roles.all. > > Of you really DO want just the ids (seriously ask yourself why), then > @user.skills.all.collect(&:id) and @user.roles.all.collect(&:id) > > -- > 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. > >-- 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.
On 16 June 2011 10:58, rajeevsharma86 <rajeevsharma86-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> not workingIt is no good just saying ''not working''. Post exactly what you have tried and exactly what the result is. By the way please don''t top post, it makes it difficult to follow the thread. Insert your replies inline at appropriate points in the previous message. Thanks. Colin> > On Thu, Jun 16, 2011 at 1:20 PM, askegg <andrew.skegg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> Your problem is here: >> >> > @user.skill_ids >> > NoMethodError: undefined method `skill_ids'' for >> > #<ActiveRecord::Relation:0x00000005515b58> >> > @user.role_ids >> > NoMethodError: undefined method `skill_ids'' for >> > #<ActiveRecord::Relation:0x00000005515b58> >> >> Try @user.skills.all and @user.roles.all. >> >> Of you really DO want just the ids (seriously ask yourself why), then >> @user.skills.all.collect(&:id) and @user.roles.all.collect(&:id) >> >> -- >> 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. >> > > -- > 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. >-- 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.
On Jun 16, 2011, at 1:22 AM, rajeevkannav wrote:> class User < ActiveRecord::Base > has_many :correlations > has_many :roles, :through => :correlations > has_many :skills, :through => :correlations > > attr_accessible > :email > , :password > , :password_confirmation > , :remember_me > , :role_ids > , :skill_ids > , :username > , :first_name > , :last_name > , :address > , :city > , :state > , :country, :phone_number, :photo,:fullname, :shortbio, :weburlWhy do you have these att_accessible things? If these are the columns from the database table users, then ActiveRecord will already take care of those. I think you should take out the entire attr_accessible line and try again. (Well, depending on how they are used, you might need to retain a `attr_accessor ... Ah, you have attr_accessible (an ActiveRecord thing) not attr_accessor (a Ruby thing).) OK, so I still wonder if having :skill_ids in that list is wrong since it is not a column, but a method added by ActiveRecord. (and same for :role_ids)> > def role?(role) > return !!self.roles.find_by_name(role.to_s.camelize) > end > def skill?(skill) > return !!self.skills.find_by_name(skill.to_s.camelize) > endUnless you actually depend on true/false rather than just truthiness, you don''t need the !! (or the return) def role?(a_role) self.roles.find_by_name(a_role.to_s.camelize) end> > end > > > class Correlation < ActiveRecord::Base > belongs_to :role > belongs_to :skill > belongs_to :user > end > > > class Skill < ActiveRecord::Base > has_many :correlations > has_many :roles, :through => :correlations > has_many :users, :through => :correlations > end > > class Role < ActiveRecord::Base > has_many :correlations > has_many :skills, :through => :correlations > has_many :users, :through => :correlations > > end > > > module ArticlesHelper > > def skill_list > skills_ids = current_user.skill_ids > skills_ids.delete_if {|x| x == nil} > skills = Skill.find(skills_ids) > return skills > end > > end > > if working fine but on heroku console > > @user.skill_ids > NoMethodError: undefined method `skill_ids'' for > #<ActiveRecord::Relation:0x00000005515b58> > @user.role_ids > NoMethodError: undefined method `skill_ids'' for > #<ActiveRecord::Relation:0x00000005515b58> > > > Any idea? > > Pleaase help > > ccdd-Rob Rob Biedenharn Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org http://AgileConsultingLLC.com/ rab-/VpnD74mH8+00s0LW7PaslaTQe2KTcn/@public.gmane.org http://GaslightSoftware.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.
hi.. please help me out m very much new to rails.. just how to create form using rails?????????? On Thu, Jun 16, 2011 at 5:59 PM, Rob Biedenharn <Rob-GBZH0y1GwQfnZcttdmLDtcI/UQi/AW5J@public.gmane.org>wrote:> > On Jun 16, 2011, at 1:22 AM, rajeevkannav wrote: > > class User < ActiveRecord::Base > has_many :correlations > has_many :roles, :through => :correlations > has_many :skills, :through => :correlations > attr_accessible :email, :password, :password_confirmation, :remember_me, > :role_ids, :skill_ids, :username, :first_name, :last_name, :address, :city, > :state , :country, :phone_number, :photo,:fullname, :shortbio, :weburl > > > Why do you have these att_accessible things? If these are the columns from > the database table users, then ActiveRecord will already take care of those. > I think you should take out the entire attr_accessible line and try again. > (Well, depending on how they are used, you might need to retain a > `attr_accessor ... Ah, you have attr_accessible (an ActiveRecord thing) not > attr_accessor (a Ruby thing).) OK, so I still wonder if having :skill_ids in > that list is wrong since it is not a column, but a method added by > ActiveRecord. (and same for :role_ids) > > > def role?(role) > return !!self.roles.find_by_name(role.to_s.camelize) > end > def skill?(skill) > return !!self.skills.find_by_name(skill.to_s.camelize) > end > > > Unless you actually depend on true/false rather than just truthiness, you > don''t need the !! (or the return) > > def role?(a_role) > self.roles.find_by_name(a_role.to_s.camelize) > end > > > end > > > class Correlation < ActiveRecord::Base > belongs_to :role > belongs_to :skill > belongs_to :user > end > > > class Skill < ActiveRecord::Base > has_many :correlations > has_many :roles, :through => :correlations > has_many :users, :through => :correlations > end > > class Role < ActiveRecord::Base > has_many :correlations > has_many :skills, :through => :correlations > has_many :users, :through => :correlations > > end > > > module ArticlesHelper > > def skill_list > skills_ids = current_user.skill_ids > skills_ids.delete_if {|x| x == nil} > skills = Skill.find(skills_ids) > return skills > end > > end > > if working fine but on heroku console > > @user.skill_ids > NoMethodError: undefined method `skill_ids'' for > #<ActiveRecord::Relation:0x00000005515b58> > @user.role_ids > NoMethodError: undefined method `skill_ids'' for > #<ActiveRecord::Relation:0x00000005515b58> > > > Any idea? > > Pleaase help > > ccdd > > > -Rob > > Rob Biedenharn > Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org http://AgileConsultingLLC.com/ > rab-/VpnD74mH8+00s0LW7PaslaTQe2KTcn/@public.gmane.org <Rob-/VpnD74mH8+00s0LW7PaslaTQe2KTcn/@public.gmane.org> > http://GaslightSoftware.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. >-- 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.