title: ruby on rails - how to make relationship works in route, controller, view ? has_many, belongs_to
body: <p>I am struggling to get my relationship in rails to work.</p>
  
  <p>I have a User,Gallery,Comment model</p>
  
  <pre><code>class Gallery  
    has_many :comments
    belongs_to :user
  end
  
  class User  
    has_many :comments
    has_many :galleries
  end
  
  class Comment
    belongs_to :gallery
    belongs_to :user
  end
  </code></pre>
  
  <p>now what should i do in the routes, controller and views to link this all up ?
  please help me ? its quite confusing finding out the answers. If can, I dont want it to be nested like in the railscast, but i want for each model, eg gallery i can input user, eg comment i can find and input the galleryid and userid.</p>
  
  <p>Im totally lost in oblivion now, not knowing what to do. Please give some assistance. thanks.</p>