I want to render Model B''s views inside Model A''s, how would I do this? For instance, I want to display the "new.html.erb" of Model B in A''s index.html.erb, and be able to create new B''s in A. Thanks. -- Posted via http://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 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 -~----------~----~----~----~------~----~------~--~---
Views correspond to controllers, not models. If that is what you mean, in Controller A, you can redirect_to B, use render :controller => :B, :action => :new, or just move new.html.erb into A''s views. Unless you are also using it for B alone, this makes more sense On Tue, Jul 15, 2008 at 4:50 PM, Justin To <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I want to render Model B''s views inside Model A''s, how would I do this? > > For instance, I want to display the "new.html.erb" of Model B in A''s > index.html.erb, and be able to create new B''s in A. > > Thanks. > -- > Posted via http://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 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 -~----------~----~----~----~------~----~------~--~---
Sean Clark Hess wrote:> Views correspond to controllers, not models. If that is what you mean, > in > Controller A, you can redirect_to B, use render :controller => :B, > :action > => :new, or just move new.html.erb into A''s views. Unless you are also > using it for B alone, this makes more sense > > On Tue, Jul 15, 2008 at 4:50 PM, Justin To > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Another option is to move the content of the view into a partial and have each parent render the partials. So you''d have something similar to controller A def new ... end views/A/new.html.erb render :partial => ''<some path to the partial>/<some partial name>'' controller B def new ... end views/B/new.html.erb render :partial => ''<some path to the partial>/<some partial name>'' If the partial you are rendering is a form, you can set instance variables containing the controller and action to post to. I''m doing something similar to this right now in that I have a particular form that I am using in three different situations. Peace, Phillip -- Posted via http://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 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 -~----------~----~----~----~------~----~------~--~---
This is what I''m trying in \controllers\users_controller.rb: rjs.replace_html :results, :partial => ''\req_details\form'' I''m trying to render \views\req_details\_form Thanks for the help -- Posted via http://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 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 -~----------~----~----~----~------~----~------~--~---
Justin To wrote:> This is what I''m trying in \controllers\users_controller.rb: > > rjs.replace_html :results, :partial => ''\req_details\form'' > > I''m trying to render \views\req_details\_form > > Thanks for the helpAre you getting some kind of error? Post all relevant code so we can have a look. Peace, Phillip -- Posted via http://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 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 -~----------~----~----~----~------~----~------~--~---
No error. When I click the link, it just seems as though nothing is happening. \views\users\_user_management.html.erb: <%= link_to_remote( "Add requirement", :url => { :action => :show_add_req } ) %> \controllers\users_controller.rb: def show_add_req if(request.xhr?) render :update do |rjs| rjs.replace_html :results, :partial => ''\req_details\form'' # tried multiple things here ''form'', ''_form'', ''\req_details\form'', ''\req_details\_form'',... rjs.visual_effect(:blind_down, "results", :duration => 1) end else redirect_to_index and return end end \views\req_details\_form.html.erb: sdfkjsdlfkjsdlfkjsldkfjsdkf That''s all of the relevant code...I think. Thanks for the help! -- Posted via http://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 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 -~----------~----~----~----~------~----~------~--~---
Justin To wrote:> \controllers\users_controller.rb: > def show_add_req > if(request.xhr?) > render :update do |rjs| > rjs.replace_html :results, :partial => ''\req_details\form'' #In which file is a dom element with the id ''results'' defined? Is it in the current page at the time of the ajax request? Peace, Phillip -- Posted via http://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 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 -~----------~----~----~----~------~----~------~--~---
Phillip Koebbe wrote:> Justin To wrote: > >> \controllers\users_controller.rb: >> def show_add_req >> if(request.xhr?) >> render :update do |rjs| >> rjs.replace_html :results, :partial => ''\req_details\form'' # > > In which file is a dom element with the id ''results'' defined? Is it in > the current page at the time of the ajax request? > > Peace, > PhillipThe ''results'' <div> is in index.html.erb -- Posted via http://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 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 -~----------~----~----~----~------~----~------~--~---
Justin To wrote:> Phillip Koebbe wrote: >> Justin To wrote: >> >>> \controllers\users_controller.rb: >>> def show_add_req >>> if(request.xhr?) >>> render :update do |rjs| >>> rjs.replace_html :results, :partial => ''\req_details\form'' # >> >> In which file is a dom element with the id ''results'' defined? Is it in >> the current page at the time of the ajax request? >> >> Peace, >> Phillip > > The ''results'' <div> is in index.html.erbOkay. Let me make sure I understand. You hit the index action which ultimately renders the partial \views\users\_user_management.html.erb. That partial includes the link_to_remote which calls the show_add_req action. That action updates the results div which is part of the index.html.erb view. So the only thing we haven''t seen yet are the contents of req_details/_form. I''m wondering if you''re missing an instance variable or something in the show_add_req action. Phillip -- Posted via http://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 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 -~----------~----~----~----~------~----~------~--~---
> Okay. Let me make sure I understand. You hit the index action which > ultimately renders the partial \views\users\_user_management.html.erb. > That partial includes the link_to_remote which calls the show_add_req > action. That action updates the results div which is part of the > index.html.erb view. So the only thing we haven''t seen yet are the > contents of req_details/_form. I''m wondering if you''re missing an > instance variable or something in the show_add_req action. > > Phillip\views\req_details\_form.html.erb: sdfkjsdlfkjsdlfkjsldkfjsdkf I just stuck that in for testing purposes... I think the problem must be in the action show_add_req def show_add_req if(request.xhr?) render :update do |rjs| rjs.replace_html :results, :partial => ''\req_details\_form'' rjs.visual_effect(:blind_down, "results", :duration => 1) end else redirect_to_index and return end end Particularly, rjs.replace_html :results (<-/users/views/index.html.erb), :partial => ?? (<-req_details/views/_form.html.erb) Thanks -- Posted via http://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 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 -~----------~----~----~----~------~----~------~--~---
Justin To wrote:> I think the problem must be in the action show_add_req > def show_add_req > if(request.xhr?) > render :update do |rjs| > rjs.replace_html :results, :partial => ''\req_details\_form'' > rjs.visual_effect(:blind_down, "results", :duration => 1) > end > else > redirect_to_index and return > end > end > > Particularly, rjs.replace_html :results (<-/users/views/index.html.erb), > :partial => ?? (<-req_details/views/_form.html.erb) > > ThanksHi Justin, I think I might have an idea. Comment out the visual_effect line and try again. I believe you''re getting an error in the javascript, and you''re just not seeing it. Are you using Firebug? You would be able to see it in there. I think your visual_effect line is incorrect at the duration. It should have the duration in curly braces as a hash, like rjs.visual_effect(:blind_down, ''results'', {:duration => 1}) At least that''s how I have always coded it. Maybe I''m wrong. It''s worth a shot, though. Peace, Phillip -- Posted via http://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 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 -~----------~----~----~----~------~----~------~--~---
Hi, all, I''m new to Rails. I''m trying to build Web sites with it with FileMaker as the back-end database. Any of you in the RTP area of North Carolina, USA? Sincerely, Chris Kubica President, Founder Application Architects 1-888-896-4608 (Ph/Fax) 1-202-280-2042 (Int''l Ph/Fax) http://www.applicationarch.com Certified FileMaker Developer FileMaker Business Alliance (FBA) Member Certified Project Management Professional (PMP) FDA, Part 11, GxP, HIPAA and SOX Compliance Experts --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Craig White
2008-Jul-17 01:49 UTC
Re: ****[Rails] Intro From Newbie in Raleigh, NC USA Area
On Wed, 2008-07-16 at 21:27 -0400, Chris Kubica wrote:> Hi, all, > > I''m new to Rails. I''m trying to build Web sites with it with FileMaker as > the back-end database. > > Any of you in the RTP area of North Carolina, USA?---- I remember you from my filemaker days. Heavily suggest that you learn rails with sql db first so that you get the power of rails before you attempt to connect to a Filemaker DB because that''s likely to be disappointing (wouldn''t know, I never tried). Once I got into Rails, Filemaker seemed so painful and I have stopped doing Filemaker. Craig --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Craig White
2008-Jul-17 01:51 UTC
Re: ****[Rails] Intro From Newbie in Raleigh, NC USA Area
On Wed, 2008-07-16 at 21:27 -0400, Chris Kubica wrote:> Hi, all, > > I''m new to Rails. I''m trying to build Web sites with it with FileMaker as > the back-end database. > > Any of you in the RTP area of North Carolina, USA?---- oh and by the way...start your own threads - don''t steal other people''s threads by clicking ''reply'' and changing the subject. Craig --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Chris Kubica
2008-Jul-17 04:28 UTC
Re: ****[Rails] Intro From Newbie in Raleigh, NC USA Area
Sorry!> From: Craig White <craigwhite-BQ75lA0ptkhBDgjK7y7TUQ@public.gmane.org> > Reply-To: <rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > Date: Wed, 16 Jul 2008 18:51:22 -0700 > To: <rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > Subject: [Rails] Re: ****[Rails] Intro From Newbie in Raleigh, NC USA Area > > > On Wed, 2008-07-16 at 21:27 -0400, Chris Kubica wrote: >> Hi, all, >> >> I''m new to Rails. I''m trying to build Web sites with it with FileMaker as >> the back-end database. >> >> Any of you in the RTP area of North Carolina, USA? > ---- > oh and by the way...start your own threads - don''t steal other people''s > threads by clicking ''reply'' and changing the subject. > > Craig > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
\views\users\_user_management.html.erb: <%= link_to_remote( "Add requirement", :url => { :action => :show_add_req } ) %> Let me try to understand , you said u have parent and child models/ views. and u wish to call daughter action from parent view. try adding controller => "daughter " to the link_to_remote url CJ(JON) ---------- On Jul 17, 9:28 am, Chris Kubica <chriskub...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Sorry! > > > From: Craig White <craigwh...-BQ75lA0ptkhBDgjK7y7TUQ@public.gmane.org> > > Reply-To: <rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > Date: Wed, 16 Jul 2008 18:51:22 -0700 > > To: <rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > Subject: [Rails] Re: ****[Rails] Intro From Newbie in Raleigh, NC USA Area > > > On Wed, 2008-07-16 at 21:27 -0400, Chris Kubica wrote: > >> Hi, all, > > >> I''m new to Rails. I''m trying to build Web sites with it with FileMaker as > >> the back-end database. > > >> Any of you in the RTP area of North Carolina, USA? > > ---- > > oh and by the way...start your own threads - don''t steal other people''s > > threads by clicking ''reply'' and changing the subject. > > > Craig--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I''m out of my league here for sure, but shouldn''t that partial reference be: :partial => ''req_details/form'' instead of: :partial => ''\req_details\_form'' ? Cheers, -Roy -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Phillip Koebbe Sent: Wednesday, July 16, 2008 6:06 PM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] Re: Rendering another model''s views Justin To wrote:> I think the problem must be in the action show_add_req > def show_add_req > if(request.xhr?) > render :update do |rjs| > rjs.replace_html :results, :partial => ''\req_details\_form'' > rjs.visual_effect(:blind_down, "results", :duration => 1) > end > else > redirect_to_index and return > end > end > > Particularly, rjs.replace_html :results > (<-/users/views/index.html.erb), :partial => ?? > (<-req_details/views/_form.html.erb) > > ThanksHi Justin, I think I might have an idea. Comment out the visual_effect line and try again. I believe you''re getting an error in the javascript, and you''re just not seeing it. Are you using Firebug? You would be able to see it in there. I think your visual_effect line is incorrect at the duration. It should have the duration in curly braces as a hash, like rjs.visual_effect(:blind_down, ''results'', {:duration => 1}) At least that''s how I have always coded it. Maybe I''m wrong. It''s worth a shot, though. Peace, Phillip -- Posted via http://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 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 -~----------~----~----~----~------~----~------~--~---