On Sun, Apr 4, 2010 at 4:17 PM, Conrad Taylor <[email protected]> wrote:

> On Sun, Apr 4, 2010 at 2:01 PM, David Zhu <[email protected]>wrote:
>
>> can i comment out- map.resources :pages in my routes? or do i need
>> that?
>>
>>
> David, it really depends on what you're trying to do.  It seems that you
> were using
> nested resources.  Thus, I would expect the following within your
> routes.rb:
>
> map.resources :courses, :has_many => :pages
> map.root :courses
>
>
Correction, it should be

map.root :controller => "courses"

-Conrad


> Good luck,
>
> -Conrad
>
>
>>  On Apr 4, 4:11 am, Srijith nair <[email protected]> wrote:
>> > Sorry!
>> > that was new method by mistake i had written it as find.
>> > map.resources :courses do |course|
>> >   course.resources :pages
>> > end
>> >
>> > <%form_for :page,:url=>course_pages_path(@course) do %>
>> > <%end%>
>> >
>> > in controller
>> > def new
>> > @course = Course.find(params[:course_id])
>> > end
>> >
>> > def create
>> > @course = Course.find(params[:course_id])
>> > @page = @course.pages.new(params[:page])
>> > @page.save
>> > end
>> >
>> > Keep rocking
>> >
>> >
>> >
>> > Conrad Taylor wrote:
>> > > On Sun, Apr 4, 2010 at 12:39 AM, Srijith nair <[email protected]>
>> > > wrote:
>> >
>> > >> <%end%>
>> >
>> > > Srijith, the second isn't correct because you're
>> > > trying to find a page that doesn't exist the database.
>> > > Thus, this will generate ActiveRecord::RecordNotFound
>> > > as would the first line if it doesn't exist and the second
>> > > should like like the following:
>> >
>> > > @page = @course.pages.build( params[:page] )
>> >
>> > > @David- make sure that you have a 'new' method
>> > > on the PagesController defined as follows:
>> >
>> > > def new
>> > >     @course = Course.find( params[:course_id] )
>> > >     @page = @course.pages.build
>> > > end
>> >
>> > > Good luck,
>> >
>> > > -Conrad
>> >
>> > --
>> > 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 [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<rubyonrails-talk%[email protected]>
>> .
>> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to