[Rails] Multiple relationships between models

2010-11-09 Thread Al Rowan
Hi, I'm fairly new to RoR and I'm trying to figure out the best way to deal with Users in my application. I've got (for the purpose of this thread) 3 models, User, Subject, and SubjectUserAssignment. The user model is joined to the Subject model with the following, creating a many to many relation

[Rails] Re: Nooby Stuck - "has_and_belongs_to_many" relationship

2010-10-12 Thread Al Rowan
through some strange coincidence, my mac crashed. after a reboot it now all works. sorry for wasting your marnen and thanks very much for your assistance. I'm quite stumped as to what actually triggered the fix, I haven't done anything really. I am using Aptana Studio 3...(still in beta) perhap

[Rails] Re: Nooby Stuck - "has_and_belongs_to_many" relationship

2010-10-12 Thread Al Rowan
solved that last error by changing it back from the extra "_id" -- 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-t...@googlegroups.com. To unsubsc

[Rails] Re: Nooby Stuck - "has_and_belongs_to_many" relationship

2010-10-12 Thread Al Rowan
dont know if this helps at all.. ?> scheme.works.empty? ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: schemes_works.scheme_id: SELECT * FROM "works" INNER JOIN "schemes_works" ON "works".id = "schemes_works".work_id WHERE ("schemes_works".scheme_id = 21 )

[Rails] Re: Nooby Stuck - "has_and_belongs_to_many" relationship

2010-10-12 Thread Al Rowan
ok so, i added the "_id" to both..same error. i also changed it from refrences to integer and it gave me the same error. -- 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, s

[Rails] Re: Nooby Stuck - "has_and_belongs_to_many" relationship

2010-10-12 Thread Al Rowan
could it be because i've used "t.refrences" and not "t.integer" I only say this because, I tried to rename the columns and it threw up the error "Missing column schemes_works.scheme" using def self.up rename_column :schemes_works, :scheme, :scheme_id rename_column :schemes_works, :work, :work_

[Rails] Re: Nooby Stuck - "has_and_belongs_to_many" relationship

2010-10-12 Thread Al Rowan
I had done a "reload!" before doing those console commands, i even rebooted! lol my schemes_work table contains a scheme and work field only. not scheme_id nor work_id should i change them? i was following the configuration from a tutorial where they did the same. so i just assumed that was ri

[Rails] Nooby Stuck - "has_and_belongs_to_many" relationship

2010-10-11 Thread Al Rowan
trying to set up a "has_and_belongs_to_many" relationship would very much appreciate the help, not sure what im doing wrong at all. Scheme.rb class Scheme < ActiveRecord::Base validates :schemename, :presence => true belongs_to :user has_many :levels, :dependent => :destroy has_

[Rails] Re: has_many - undefined method!

2010-09-22 Thread Al Rowan
activesupport (3.0.0) lib/active_support/whiny_nil.rb:48:in `method_missing' app/controllers/groups_controller.rb:8:in `create' actionpack (3.0.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action' actionpack (3.0.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action

[Rails] Re: has_many - undefined method!

2010-09-22 Thread Al Rowan
class User < ActiveRecord::Base attr_accessor :password validates :email, :uniqueness => true, :length => { :within => 5..50 }, :format => { :with => /^...@][\w.-]+@[\w.-]+[.][a-z]{2,4}$/i } validates :password, :confirmation => true,

[Rails] has_many - undefined method!

2010-09-22 Thread Al Rowan
Hi all, still new at this lol, trying to create a one to many relationship i have: group.rb [ belongs_to :user ] user.rb [ has_many :groups ] but if i do "user.groups" it just throws up: "NoMethodError: undefined method 'groups'.." again thanks for any help! Al -- Posted via http://www.ru

[Rails] Re: undifined method! driving me insane!

2010-09-22 Thread Al Rowan
radhames brito wrote: > next time type rake routes and look at the names of the helpers there > you > will see the helper for the show action is > > profile_path no show_profile_path, the output of rake route does not add > the > path ad the end because it could be something else > > like url,

[Rails] undifined method! driving me insane!

2010-09-22 Thread Al Rowan
Hi all, im new to ruby on rails, this is my first project and im stuck on a rather (i expect) simple problem. :( ive made a link <%= link_to "Profile", show_profile_path %> in my main application.html.erb i have a profiles_controller.rb with the method "show" in it "def show @profile = Prof