Hi I get this error: Showing workouts/show.html.erb where line #14 raised: undefined method `activities_path'' for #<ActionView::Base:0x720828> Extracted source (around line #14): 11: 12: <h1>Add an exercise to this Workout</h1> 13: <div id="submitArea" class="formEnd"> 14: <% form_for(:activity, :url => activities_path(@workout)) do |f| %> 15: <% render :partial => ''activities/form'', :locals => {:f => f}%> 16: <% end %> 17: </div> The top of my routes.rb looks like this: ActionController::Routing::Routes.draw do |map| map.resources :workouts do |workout| workout.resources :activities end . . Can anyone give me a clue about what I''ve done wrong? Edward --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Try for <% form_for @activity do |form| %> :) Bala On Tue, Sep 9, 2008 at 4:53 PM, CountBrass <edward.kenworthy-BUHhN+a2lJ4@public.gmane.org> wrote:> > Hi > > I get this error: > > Showing workouts/show.html.erb where line #14 raised: > > undefined method `activities_path'' for #<ActionView::Base:0x720828> > Extracted source (around line #14): > > 11: > 12: <h1>Add an exercise to this Workout</h1> > 13: <div id="submitArea" class="formEnd"> > 14: <% form_for(:activity, :url => activities_path(@workout)) > do |f| > %> > 15: <% render :partial => ''activities/form'', :locals => > {:f => f}%> > 16: <% end %> > 17: </div> > > The top of my routes.rb looks like this: > > ActionController::Routing::Routes.draw do |map| > > map.resources :workouts do |workout| > workout.resources :activities > end > . > . > > Can anyone give me a clue about what I''ve done wrong? > > Edward > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
''Fraid that doesn''t work. The ''add activity'' is part of the Workout show page and the @activity in your code is nil. On Sep 9, 12:41 pm, "bala kishore pulicherla" <balumc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Try for > <% form_for @activity do |form| %> > > :) > > Bala > > On Tue, Sep 9, 2008 at 4:53 PM, CountBrass <edward.kenwor...-BUHhN+a2lJ4@public.gmane.org> wrote: > > > Hi > > > I get this error: > > > Showing workouts/show.html.erb where line #14 raised: > > > undefined method `activities_path'' for #<ActionView::Base:0x720828> > > Extracted source (around line #14): > > > 11: > > 12: <h1>Add an exercise to this Workout</h1> > > 13: <div id="submitArea" class="formEnd"> > > 14: <% form_for(:activity, :url => activities_path(@workout)) > > do |f| > > %> > > 15: <% render :partial => ''activities/form'', :locals => > > {:f => f}%> > > 16: <% end %> > > 17: </div> > > > The top of my routes.rb looks like this: > > > ActionController::Routing::Routes.draw do |map| > > > map.resources :workouts do |workout| > > workout.resources :activities > > end > > . > > . > > > Can anyone give me a clue about what I''ve done wrong? > > > Edward--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
i thought an activity has_many workouts :( itz in the reverse way :) try for <% form_for [@activity, @workout] do |form| %> hope it will work :) Bala On Tue, Sep 9, 2008 at 5:22 PM, CountBrass <edward.kenworthy-BUHhN+a2lJ4@public.gmane.org> wrote:> > ''Fraid that doesn''t work. The ''add activity'' is part of the Workout > show page and the @activity in your code is nil. > > On Sep 9, 12:41 pm, "bala kishore pulicherla" <balumc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > Try for > > <% form_for @activity do |form| %> > > > > :) > > > > Bala > > > > On Tue, Sep 9, 2008 at 4:53 PM, CountBrass <edward.kenwor...-BUHhN+a2lJ4@public.gmane.org> > wrote: > > > > > Hi > > > > > I get this error: > > > > > Showing workouts/show.html.erb where line #14 raised: > > > > > undefined method `activities_path'' for #<ActionView::Base:0x720828> > > > Extracted source (around line #14): > > > > > 11: > > > 12: <h1>Add an exercise to this Workout</h1> > > > 13: <div id="submitArea" class="formEnd"> > > > 14: <% form_for(:activity, :url => > activities_path(@workout)) > > > do |f| > > > %> > > > 15: <% render :partial => ''activities/form'', > :locals => > > > {:f => f}%> > > > 16: <% end %> > > > 17: </div> > > > > > The top of my routes.rb looks like this: > > > > > ActionController::Routing::Routes.draw do |map| > > > > > map.resources :workouts do |workout| > > > workout.resources :activities > > > end > > > . > > > . > > > > > Can anyone give me a clue about what I''ve done wrong? > > > > > Edward > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
''fraid that doesnt work either. NoMethodError in Workouts#show Showing workouts/show.html.erb where line #15 raised: undefined method `nil_class_workout_path'' for #<ActionView::Base: 0x1637cf8> Extracted source (around line #15): 12: <h1>Add an activity to this Workout</h1> 13: <div id="submitArea" class="formEnd"> 14: 15: <% form_for [@activity, @workout] do |f| %> 16: 17: <% render :partial => ''activities/form'', :locals => {:f => f}%> 18: <% end %> On 9 Sep 2008, at 12:58, bala kishore pulicherla wrote:> i thought an activity has_many workouts :( > > itz in the reverse way :) > > try for > <% form_for [@activity, @workout] do |form| %> > > > hope it will work > :) > > Bala > > On Tue, Sep 9, 2008 at 5:22 PM, CountBrass <edward.kenworthy-BUHhN+a2lJ4@public.gmane.org> > wrote: > > ''Fraid that doesn''t work. The ''add activity'' is part of the Workout > show page and the @activity in your code is nil. > > On Sep 9, 12:41 pm, "bala kishore pulicherla" <balumc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > Try for > > <% form_for @activity do |form| %> > > > > :) > > > > Bala > > > > On Tue, Sep 9, 2008 at 4:53 PM, CountBrass > <edward.kenwor...-BUHhN+a2lJ4@public.gmane.org> wrote: > > > > > Hi > > > > > I get this error: > > > > > Showing workouts/show.html.erb where line #14 raised: > > > > > undefined method `activities_path'' for #<ActionView::Base: > 0x720828> > > > Extracted source (around line #14): > > > > > 11: > > > 12: <h1>Add an exercise to this Workout</h1> > > > 13: <div id="submitArea" class="formEnd"> > > > 14: <% form_for(:activity, :url => > activities_path(@workout)) > > > do |f| > > > %> > > > 15: <% render :partial => ''activities/ > form'', :locals => > > > {:f => f}%> > > > 16: <% end %> > > > 17: </div> > > > > > The top of my routes.rb looks like this: > > > > > ActionController::Routing::Routes.draw do |map| > > > > > map.resources :workouts do |workout| > > > workout.resources :activities > > > end > > > . > > > . > > > > > Can anyone give me a clue about what I''ve done wrong? > > > > > Edward > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
:o Do u did before_filtter for the workut to load the activity??? if not so do that in this way i assume the fallowing relation ship b/w models depending on ur routes Model Workout has_many :activities Model Activity belongs_to :workout In the workout controller i assume def new @workout= Workout.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @workout} end end def create @workout= Workout.new(params[:workout]) respond_to do |format| if @workout.save format.html { redirect_to(@workout) } format.xml { render :xml => @workout, :status => :created, :location => @workout} else format.html { render :action => "new" } format.xml { render :xml => @workout.errors, :status => :unprocessable_entity } end end end in ur activity controller before_filter :find_workout def new @activity= Activity.new end def create @activity = Activity.new(params[:activity]) if (@workout.activities << @activity) redirect_to workout_url(@workout) else render :action => :new end end private def find_workout @workout_id = params[:workout_id] return(redirect_to(workouts_url)) unless @workout_id @workout= Workout.find(@workout_id) end and ur view file for activity/new <% form_for [@workout, @activity] do |form| %> <fieldset> <legend>Add an Activity</legend> <%= render :partial => ''form'', :object => form %> <p> <%= submit_tag "Create" %> </p> </fieldset> <% end %> *and the link for the new activity will be <%= link_to "Add Activity", new_workout_activity_url(@workout) %> * *and ur routes map.resources :workouts do |workout| workout.resources :activities end* If still any issues :o let us know :) :) Bala Kishore On Tue, Sep 9, 2008 at 6:40 PM, Edward Kenworthy <edward.kenworthy-BUHhN+a2lJ4@public.gmane.org>wrote:> ''fraid that doesnt work either. > NoMethodError in Workouts#show > > Showing *workouts/show.html.erb* where line *#15* raised: > > undefined method `nil_class_workout_path'' for #<ActionView::Base:0x1637cf8> > > > Extracted source (around line *#15*): > > 12: <h1>Add an activity to this Workout</h1> > 13: <div id="submitArea" class="formEnd"> > 14: > 15: <% form_for [@activity, @workout] do |f| %> > 16: > 17: <% render :partial => ''activities/form'', :locals => {:f => f}%> > 18: <% end %> > > > On 9 Sep 2008, at 12:58, bala kishore pulicherla wrote: > > i thought an activity has_many workouts :( > > itz in the reverse way :) > > try for > <% form_for [@activity, @workout] do |form| %> > > > hope it will work > :) > > Bala > > On Tue, Sep 9, 2008 at 5:22 PM, CountBrass <edward.kenworthy-BUHhN+a2lJ4@public.gmane.org>wrote: > >> >> ''Fraid that doesn''t work. The ''add activity'' is part of the Workout >> show page and the @activity in your code is nil. >> >> On Sep 9, 12:41 pm, "bala kishore pulicherla" <balumc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> wrote: >> > Try for >> > <% form_for @activity do |form| %> >> > >> > :) >> > >> > Bala >> > >> > On Tue, Sep 9, 2008 at 4:53 PM, CountBrass <edward.kenwor...-BUHhN+a2lJ4@public.gmane.org> >> wrote: >> > >> > > Hi >> > >> > > I get this error: >> > >> > > Showing workouts/show.html.erb where line #14 raised: >> > >> > > undefined method `activities_path'' for #<ActionView::Base:0x720828> >> > > Extracted source (around line #14): >> > >> > > 11: >> > > 12: <h1>Add an exercise to this Workout</h1> >> > > 13: <div id="submitArea" class="formEnd"> >> > > 14: <% form_for(:activity, :url => >> activities_path(@workout)) >> > > do |f| >> > > %> >> > > 15: <% render :partial => ''activities/form'', >> :locals => >> > > {:f => f}%> >> > > 16: <% end %> >> > > 17: </div> >> > >> > > The top of my routes.rb looks like this: >> > >> > > ActionController::Routing::Routes.draw do |map| >> > >> > > map.resources :workouts do |workout| >> > > workout.resources :activities >> > > end >> > > . >> > > . >> > >> > > Can anyone give me a clue about what I''ve done wrong? >> > >> > > Edward >> >> > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
simply changing this form_for(:activity, :url => activities_path(@workout)) to form_for(:activity, :url => workouts_activities_path(@workout)) should work On Sep 9, 12:23 pm, CountBrass <edward.kenwor...-BUHhN+a2lJ4@public.gmane.org> wrote:> Hi > > I get this error: > > Showing workouts/show.html.erb where line #14 raised: > > undefined method `activities_path'' for #<ActionView::Base:0x720828> > Extracted source (around line #14): > > 11: > 12: <h1>Add an exercise to this Workout</h1> > 13: <div id="submitArea" class="formEnd"> > 14: <% form_for(:activity, :url => activities_path(@workout)) do |f| > %> > 15: <% render :partial => ''activities/form'', :locals => {:f => f}%> > 16: <% end %> > 17: </div> > > The top of my routes.rb looks like this: > > ActionController::Routing::Routes.draw do |map| > > map.resources :workouts do |workout| > workout.resources :activities > end > . > . > > Can anyone give me a clue about what I''ve done wrong? > > Edward--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---