Hi, I have a simple sideblog with my posts in it. I can see 5 last posts in my index action. Could I add form to submit a new post at the top of my posts? I dont know how to render new post action in my index action to show the form. THX -- 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 -~----------~----~----~----~------~----~------~--~---
You can''t render one action in another. What you should do is put the submit form in a partial (call it _form.html.erb) . See http://railscasts.com/episodes/80 for more info. In both your new and index action you put <%= render :partial => @post %>. Don''t forget to instantiate @post in both your index and new controller - @post = Post.new . You ofcourse can also do this in the partial but that''s not really MVCish. I hope this helps. Stijn On 24 nov, 10:01, Petan Cert <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, > > I have a simple sideblog with my posts in it. I can see 5 last posts in > my index action. Could I add form to submit a new post at the top of my > posts? I dont know how to render new post action in my index action to > show the form. THX > -- > 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 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 -~----------~----~----~----~------~----~------~--~---
Thx for your help. Could I do the same thing (:partial =>) even with another controller? I quess not. Thx. Pete -- 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 -~----------~----~----~----~------~----~------~--~---
Do you mean call a controller via :partial => ? No, that''s not possible. On 24 nov, 14:20, Petan Cert <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Thx for your help. Could I do the same thing (:partial =>) even with > another controller? I quess not. Thx. Pete > -- > 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 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 -~----------~----~----~----~------~----~------~--~---
All right, thanks. I have got a users and entries controller. Users homepage is www.mydomain.com/profile/:username (:controller => ''users'', :action => ''show''). Users can add a new posts in (:controller => ''entries'', :action => ''new'') and I would like to allow users to add and see their posts at profile page, which is in users controller. Is there way out of this? Hope, yes. Thank you. Pete Tarscher wrote:> Do you mean call a controller via :partial => ? No, that''s not > possible.-- 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 Pete, That''s perfectly possible. in your user show view def show @entry = Entry.new end in your user show view // when using form_for @entry rails will know that your form is intended for the entries controller and will point you there automatically. form_for @entry do |f| // form elements here end Don''t forget to redirect to the user show view in your entries create action. I hope this helps. Stijn On 25 nov, 17:47, Petan Cert <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> All right, thanks. I have got a users and entries controller. Users > homepage iswww.mydomain.com/profile/:username(:controller => ''users'', > :action => ''show''). Users can add a new posts in (:controller => > ''entries'', :action => ''new'') and I would like to allow users to add and > see their posts at profile page, which is in users controller. Is there > way out of this? Hope, yes. Thank you. > Pete > > Tarscherwrote: > > Do you mean call a controller via :partial => ? No, that''s not > > possible. > > -- > 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 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 Stijn, thank you very much, it is exactly what I was hoping for. Pete -- 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 -~----------~----~----~----~------~----~------~--~---