hi, i''ve written an app but failing on one pivotal part, i have a user model built, and a notes model built now, once the user navigates to the notes view they can create notes and they will only be available to that user. i''ve got it saving the user_id to the note record, but not filtering out only notes for that current user. any ideas? sample code <% for note in @notes %> <tr> <% for column in Note.content_columns %> <td><%=h note.send(column.name) %></td> <% end %> <td><%= link_to ''Show'', :action => ''show'', :id => note %></td> <td><%= link_to ''Edit'', :action => ''edit'', :id => note %></td> <td><%= link_to ''Destroy'', { :action => ''destroy'', :id => note }, :confirm => ''Are you sure?'', :method => :post %></td> </tr> <% end %> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
filter it in the controller: def show @notes = Note.find(:all, :conditions => ["user_id = ?", @current_user.id] end On Jul 30, 4:49 pm, jag <indieh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi, i''ve written an app but failing on one pivotal part, > > i have a user model built, and a notes model built > > now, once the user navigates to the notes view they can create notes > and they will only be available to that user. > > i''ve got it saving the user_id to the note record, but not filtering > out only notes for that current user. > > any ideas? > > sample code > > <% for note in @notes %> > <tr> > <% for column in Note.content_columns %> > <td><%=h note.send(column.name) %></td> > <% end %> > <td><%= link_to ''Show'', :action => ''show'', :id => note %></td> > <td><%= link_to ''Edit'', :action => ''edit'', :id => note %></td> > <td><%= link_to ''Destroy'', { :action => ''destroy'', :id => > note }, :confirm => ''Are you sure?'', :method => :post %></td> > </tr> > <% end %>--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 7/31/07, jemminger <jemminger-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > filter it in the controller: > > def show > @notes = Note.find(:all, :conditions => ["user_id = ?", > @current_user.id] > endOr to use the has_many :notes association in the User model def show @notes = @current_user.notes end On Jul 30, 4:49 pm, jag <indieh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > hi, i''ve written an app but failing on one pivotal part, > > > > i have a user model built, and a notes model built > > > > now, once the user navigates to the notes view they can create notes > > and they will only be available to that user. > > > > i''ve got it saving the user_id to the note record, but not filtering > > out only notes for that current user. > > > > any ideas? > > > > sample code > > > > <% for note in @notes %> > > <tr> > > <% for column in Note.content_columns %> > > <td><%=h note.send(column.name) %></td> > > <% end %> > > <td><%= link_to ''Show'', :action => ''show'', :id => note %></td> > > <td><%= link_to ''Edit'', :action => ''edit'', :id => note %></td> > > <td><%= link_to ''Destroy'', { :action => ''destroy'', :id => > > note }, :confirm => ''Are you sure?'', :method => :post %></td> > > </tr> > > <% end %> > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
ah yes, even better! On Jul 30, 9:39 pm, "Daniel N" <has....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 7/31/07, jemminger <jemmin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > filter it in the controller: > > > def show > > @notes = Note.find(:all, :conditions => ["user_id = ?", > > @current_user.id] > > end > > Or to use the has_many :notes association in the User model > > def show > @notes = @current_user.notes > end > > On Jul 30, 4:49 pm, jag <indieh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > hi, i''ve written an app but failing on one pivotal part, > > > > i have a user model built, and a notes model built > > > > now, once the user navigates to the notes view they can create notes > > > and they will only be available to that user. > > > > i''ve got it saving the user_id to the note record, but not filtering > > > out only notes for that current user. > > > > any ideas? > > > > sample code > > > > <% for note in @notes %> > > > <tr> > > > <% for column in Note.content_columns %> > > > <td><%=h note.send(column.name) %></td> > > > <% end %> > > > <td><%= link_to ''Show'', :action => ''show'', :id => note %></td> > > > <td><%= link_to ''Edit'', :action => ''edit'', :id => note %></td> > > > <td><%= link_to ''Destroy'', { :action => ''destroy'', :id => > > > note }, :confirm => ''Are you sure?'', :method => :post %></td> > > > </tr> > > > <% end %>--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---