Hello, I have this models class Berichten < ActiveRecord::Base attr_accessible :bericht, :user belongs_to :user belongs_to :Category end class User < ActiveRecord::Base attr_accessible :email, :name has_many :berichten end class Category < ActiveRecord::Base attr_accessible :id :name has_many :berichten end What I wonder is what the right url is when I want to place a new bericht into a specific category. Is it localhost:3000/<categoryname>/bericht/new ? Roelof -- 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 To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/B6Zj-4apP7wJ. For more options, visit https://groups.google.com/groups/opt_out.
On Thu, Oct 11, 2012 at 4:23 AM, roelof <rwobben-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> class Berichten < ActiveRecord::Base > attr_accessible :bericht, :user > belongs_to :user > belongs_to :Category"Category" there should not be capitalized> end> What I wonder is what the right url is when I want to place a new bericht > into a specific category. > Is it localhost:3000/<categoryname>/bericht/new ?Why don''t you run `rake routes` and see the URLs that have been automatically defined by your relationships? You might also want to read the comments in config/routes.rb about "nested resources". -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- 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 https://groups.google.com/groups/opt_out.
On Thu, Oct 11, 2012 at 6:23 AM, roelof <rwobben-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> Hello, > > I have this models > > class Berichten < ActiveRecord::Base > attr_accessible :bericht, :user > belongs_to :user > belongs_to :Category > end > > class User < ActiveRecord::Base > attr_accessible :email, :name > has_many :berichten > end > > class Category < ActiveRecord::Base > attr_accessible :id :name > has_many :berichten > end > > What I wonder is what the right url is when I want to place a new bericht > into a specific category. > Is it localhost:3000/<categoryname>/bericht/new ?It depends on how you setup your resource and how you setup your controller. The model does not interact with the view and the view should not interact with the model directly under any circumstance, the controller hits up the model and then setups the view. Since you only showed us your model''s and not your controllers we have no idea how you have it setup, though you can read more about routing here: http://guides.rubyonrails.org/routing.html#crud-verbs-and-actions -- 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 https://groups.google.com/groups/opt_out.
Try to run rake routes to see all the routes of your current application. -- 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 To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/PCvguqo-gE4J. For more options, visit https://groups.google.com/groups/opt_out.
The controllers looks now like this : class BerichtenController < ApplicationController def new end def index @berichten = Berichten.all end def delete end def show end end class And the other controller: lass UsersController < ApplicationController def new end def index @user = User.all end def delete end def show end end My routes.rb Tamara::Application.routes.draw do resources "berichten" resources "users" resources ¨category¨ end Roelof Op donderdag 11 oktober 2012 14:26:38 UTC+2 schreef Jordon Bedwell het volgende:> > On Thu, Oct 11, 2012 at 6:23 AM, roelof <rwo...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org <javascript:>> > wrote: > > Hello, > > > > I have this models > > > > class Berichten < ActiveRecord::Base > > attr_accessible :bericht, :user > > belongs_to :user > > belongs_to :Category > > end > > > > class User < ActiveRecord::Base > > attr_accessible :email, :name > > has_many :berichten > > end > > > > class Category < ActiveRecord::Base > > attr_accessible :id :name > > has_many :berichten > > end > > > > What I wonder is what the right url is when I want to place a new > bericht > > into a specific category. > > Is it localhost:3000/<categoryname>/bericht/new ? > > It depends on how you setup your resource and how you setup your > controller. The model does not interact with the view and the view > should not interact with the model directly under any circumstance, > the controller hits up the model and then setups the view. > > Since you only showed us your model''s and not your controllers we have > no idea how you have it setup, though you can read more about routing > here: http://guides.rubyonrails.org/routing.html#crud-verbs-and-actions >-- 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. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/KAUBKrZl1WwJ. For more options, visit https://groups.google.com/groups/opt_out.