Hi Guys, The answer to this is probably pretty simple but I have an app which holds projects, and have messages for each project. project has_many messages message belongs to project in my project controller i just do @project_messages = @project.messages.collect In my project view page you can see the messages (but they are truncated to save space). I want to have a "more" link that takes the user to another page which holds all the full project messages. Do I create a page called messages.html.erb? I would also like to be able to comment on each of the messages on the second page!?!? Please can someone help me as I am a really stuck! Thank you very much!! Dave -- 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 -~----------~----~----~----~------~----~------~--~---
> In my project view page you can see the messages (but they are truncated > to save space). I want to have a "more" link that takes the user to > another page which holds all the full project messages. > > Do I create a page called messages.html.erb? > > I would also like to be able to comment on each of the messages on the > second page!?!? > > Please can someone help me as I am a really stuck! > > Thank you very much!! > > DaveAnyone? -- 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 -~----------~----~----~----~------~----~------~--~---
What did you name the method in your project controller? On Jan 5, 5:40 am, Dave Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > In my project view page you can see the messages (but they are truncated > > to save space). I want to have a "more" link that takes the user to > > another page which holds all the full project messages. > > > Do I create a page called messages.html.erb? > > > I would also like to be able to comment on each of the messages on the > > second page!?!? > > > Please can someone help me as I am a really stuck! > > > Thank you very much!! > > > Dave > > Anyone? > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bobnation wrote:> What did you name the method in your project controller? > > On Jan 5, 5:40�am, Dave Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Hi, Im not sure if I am going about this the right way but, ive created a partial called _message in the project view with the following link; -------------------------------------------------------------------------- <% for message in @project_messages %> <%= render :partial => "message", :object => message %> <% end %> -------------------------------------------------------------------------- and the following code in the _message partial. ---------------------------------------------------------------------------- <table> <tr> <th><%= message.status %> - <%= message.title %></th> </tr> <tr> <td><%= truncate(message.body, 60, "...") %> <%= link_to ''continue...'', message_path(@project) %></td> </tr> </table> This works to view the messages within the project view page. But I want to be able to view all the messages for a project in thier entirety on a different page and create comments for each message... My Projects controller show def currently looks like this; def show @project = Project.find(params[:id]) @project_tasks = @project.tasks.collect @project_messages = @project.messages.collect respond_to do |format| format.html # show.html.erb format.xml { render :xml => @project } end end -- 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 -~----------~----~----~----~------~----~------~--~---
Do you want the second page to contain all the messages or just 1 message? Cheers, Sazima On Jan 5, 8:40 am, Dave Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi Guys, > > The answer to this is probably pretty simple but I have an app which > holds projects, and have messages for each project. > > project has_many messages > message belongs to project > > in my project controller i just do > > @project_messages = @project.messages.collect > > In my project view page you can see the messages (but they are truncated > to save space). I want to have a "more" link that takes the user to > another page which holds all the full project messages. > > Do I create a page called messages.html.erb? > > I would also like to be able to comment on each of the messages on the > second page!?!? > > Please can someone help me as I am a really stuck! > > Thank you very much!! > > Dave > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sazima wrote:> Do you want the second page to contain all the messages or just 1 > message? > > Cheers, Sazima > > On Jan 5, 8:40�am, Dave Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>all the messages for a particular project, and then a section under for comments to be made for each message (kind of indented if you know what i mean) -- 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 -~----------~----~----~----~------~----~------~--~---
Dave Smith wrote:> Sazima wrote: >> Do you want the second page to contain all the messages or just 1 >> message? >> >> Cheers, Sazima >> >> On Jan 5, 8:40�am, Dave Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > all the messages for a particular project, and then a section under for > comments to be made for each message (kind of indented if you know what > i mean)i just thought i could create a partial and reference to it from both the project view page and another page such by passing in the project id somehow. -- 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 -~----------~----~----~----~------~----~------~--~---
Sazima wrote:> Do you want the second page to contain all the messages or just 1 > message? > > Cheers, Sazima > > On Jan 5, 8:40�am, Dave Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>? -- 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 -~----------~----~----~----~------~----~------~--~---
If this 2nd page you want will contain only 1 message, then it is the standard show action + view... Otherwise you can add a named route and use whatever name you want for the action and view. But it can be trickier to add comments. Cheers, Sazima On Jan 5, 3:05 pm, Dave Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Sazima wrote: > > Do you want the second page to contain all the messages or just 1 > > message? > > > Cheers, Sazima > > > On Jan 5, 8:40 am, Dave Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > ? > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sazima wrote:> If this 2nd page you want will contain only 1 message, then it is the > standard show action + view... Otherwise you can add a named route and > use whatever name you want for the action and view. But it can be > trickier to add comments. > > Cheers, Sazima > > On Jan 5, 3:05�pm, Dave Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>ok if for now i say i just want all messages, no comments. how would i go about adding the named route and view? -- 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 -~----------~----~----~----~------~----~------~--~---
1. Route (config/routes.rb): map.with_options(:controller => ''messages'') do |m| m.messages ''/messages'', :action => ''messages'' end 2. Action (app/controllers/messages_controller.rb): def messages # Retrieve messages the same way you did in the index action end 3. View (app/views/messages/messages.html.erb) => do the same as in index, but showing the whole message... Cheers, Sazima On Jan 5, 3:20 pm, Dave Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Sazima wrote: > > If this 2nd page you want will contain only 1 message, then it is the > > standard show action + view... Otherwise you can add a named route and > > use whatever name you want for the action and view. But it can be > > trickier to add comments. > > > Cheers, Sazima > > > On Jan 5, 3:05 pm, Dave Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > ok if for now i say i just want all messages, no comments. how would i > go about adding the named route and view? > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sazima wrote:> 1. Route (config/routes.rb): > > map.with_options(:controller => ''messages'') do |m| > m.messages ''/messages'', :action => ''messages'' > end > > 2. Action (app/controllers/messages_controller.rb): > > def messages > # Retrieve messages the same way you did in the index action > end > > 3. View (app/views/messages/messages.html.erb) => do the same as in > index, but showing the whole message... > > Cheers, Sazima > > On Jan 5, 3:20�pm, Dave Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>im slightly confused. i was returning the messages in the projects controller by doing @project_messages = @project.messages.collect -- 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 -~----------~----~----~----~------~----~------~--~---
Woah. Firstly, why are you calling .collect on project.messages and everything? This is unnecessary. Secondly, if messages is an association for a project it would be better if you used nested routes, as explained here: http://guides.rails.info/routing_outside_in.html . Your controller would be called messages_controller and the action would be called index, not messages. ----- Ryan Bigg Freelancer http://frozenplague.net On 06/01/2009, at 6:02 AM, Dave Smith wrote:> > Sazima wrote: >> 1. Route (config/routes.rb): >> >> map.with_options(:controller => ''messages'') do |m| >> m.messages ''/messages'', :action => ''messages'' >> end >> >> 2. Action (app/controllers/messages_controller.rb): >> >> def messages >> # Retrieve messages the same way you did in the index action >> end >> >> 3. View (app/views/messages/messages.html.erb) => do the same as in >> index, but showing the whole message... >> >> Cheers, Sazima >> >> On Jan 5, 3:20�pm, Dave Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > im slightly confused. i was returning the messages in the projects > controller by doing > > @project_messages = @project.messages.collect > > -- > 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 -~----------~----~----~----~------~----~------~--~---
Ryan, If I understood correctly, he already has an index action that shows truncated messages. He asked for a 2nd page to show the whole content of all messages. He would probably be better off using a nested route for only 1 action (index) and retrieving the rest of the message asynchronously with AJAX on-demand, but that might be too much at once. Cheers, Sazima On Jan 5, 7:05 pm, Ryan Bigg <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Woah. > > Firstly, why are you calling .collect on project.messages and > everything? This is unnecessary. > > Secondly, if messages is an association for a project it would be > better if you used nested routes, as explained here:http://guides.rails.info/routing_outside_in.html > . Your controller would be called messages_controller and the action > would be called index, not messages. > ----- > Ryan Bigg > Freelancerhttp://frozenplague.net > > On 06/01/2009, at 6:02 AM, Dave Smith wrote: > > > > > Sazima wrote: > >> 1. Route (config/routes.rb): > > >> map.with_options(:controller => ''messages'') do |m| > >> m.messages ''/messages'', :action => ''messages'' > >> end > > >> 2. Action (app/controllers/messages_controller.rb): > > >> def messages > >> # Retrieve messages the same way you did in the index action > >> end > > >> 3. View (app/views/messages/messages.html.erb) => do the same as in > >> index, but showing the whole message... > > >> Cheers, Sazima > > >> On Jan 5, 3:20 pm, Dave Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > > im slightly confused. i was returning the messages in the projects > > controller by doing > > > @project_messages = @project.messages.collect > > > -- > > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ryan Bigg wrote:> Woah. > > Firstly, why are you calling .collect on project.messages and > everything? This is unnecessary. > > Secondly, if messages is an association for a project it would be > better if you used nested routes, as explained here: > http://guides.rails.info/routing_outside_in.html > . Your controller would be called messages_controller and the action > would be called index, not messages. > ----- > Ryan Bigg > Freelancer > http://frozenplague.netThanks for your help. Ive created a nested route, and now have my messages for the project which is fine. The next problem comes from getting the comments for each message in this index page. I am not quite sure how I can retrieve the comments per message in the index in my controller.... -- 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 -~----------~----~----~----~------~----~------~--~---
>> ----- >> Ryan Bigg >> Freelancer >> http://frozenplague.net > > Thanks for your help. > > Ive created a nested route, and now have my messages for the project > which is fine. The next problem comes from getting the comments for each > message in this index page. > > I am not quite sure how I can retrieve the comments per message in the > index in my controller....any ideas at all? -- 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 -~----------~----~----~----~------~----~------~--~---
Dave Smith wrote:> >>> ----- >>> Ryan Bigg >>> Freelancer >>> http://frozenplague.net >> >> Thanks for your help. >> >> Ive created a nested route, and now have my messages for the project >> which is fine. The next problem comes from getting the comments for each >> message in this index page. >> >> I am not quite sure how I can retrieve the comments per message in the >> index in my controller.... > > any ideas at all?i am having the same problem as this for another part of the system. i need to collect on the projects index page a list of the invoices associated with that project but am unsure how to do this. It is easy on the view page as you can loop through and collect them, but how can I do this on the index page? The answer to this will answer the previous questions as well..! -- 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 -~----------~----~----~----~------~----~------~--~---