Hey everyone, I have to define a new function(called it "send") in my controller(newsletter_controller.rb). In the routes.rb I added the following line match ''newsletters/send'' => ''newsletters#show'', :as => :send and in the html.erb I try to use the action send by: <%= link_to ''Send Newsletter'', :action => :send %> Everything is in the same controller(newsletters) however the error occures No route matches {:action=>"send", :controller=>"newsletters"} Do I have to tell Rails that there is a new function in the controller? Because it looks like Rails just can''t find the function send... Is the match correct? I''m not really sure about the syntax of it and which element means what... Thanks for 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> match ''newsletters/send'' => ''newsletters#show'', :as => :send >this makes no sense, if you have resources :newsletters declared and you are pointing at the show action witch has this form newsletters/:id and then you are not passing an id, it is correctly says that no route matches since the show action needs an id. What is that you are trying to achieve? because you appear to be wanting to point to a send action in the controller but then you make match point at the show action with this ''newsletters#show''>-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
In my controller in the function send is a method to send Newsletters via email. In show.html.erb the newsletter is shown to the administrator who is able to send it, by clicking on a button "Send Newsletter".> What is that you are trying to achieve? because you appear to be wanting > to point to a send action in the controllerI thought it would be nice to see the Newsletter again after it was sent. I hope this answers your questions. 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Dec 9, 2010 at 11:48 AM, Susanne P. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> In my controller in the function send is a method to send Newsletters > via email. In show.html.erb the newsletter is shown to the administrator > who is able to send it, by clicking on a button "Send Newsletter". > > > What is that you are trying to achieve? because you appear to be wanting > > to point to a send action in the controller > > I thought it would be nice to see the Newsletter again after it was > sent. > I hope this answers your questions. > >kind of does. first if you want to point to an action you should do resources :newsletters do get ''send'', :on => :member end if the controller is restful it should be this will create something like newsletters/:id/send in the controller inside the send action redirect to the show action at the end to show the news letter -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Susanne P. wrote in post #967430:> Hey everyone, > > I have to define a new function(called it "send") in my > controller(newsletter_controller.rb). In the routes.rb I added the > following line > match ''newsletters/send'' => ''newsletters#show'', :as => :send > > and in the html.erb I try to use the action send by: > <%= link_to ''Send Newsletter'', :action => :send %> > > Everything is in the same controller(newsletters) however the error > occures No route matches {:action=>"send", :controller=>"newsletters"} > > > > Do I have to tell Rails that there is a new function in the controller? > Because it looks like Rails just can''t find the function send...Does the send method exist yet?> Is the match correct? I''m not really sure about the syntax of it and > which element means what...http://railsapi.com/doc/rails-v3.0.1/classes/ActionDispatch/Routing.html> > Thanks for help!Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 9 December 2010 14:54, Susanne P. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hey everyone, > > I have to define a new function(called it "send") in my > controller(newsletter_controller.rb). > > Everything is in the same controller(newsletters) however the error > occures No route matches {:action=>"send", :controller=>"newsletters"}You may run into problems because "send" is a reserved word: http://wiki.rubyonrails.org/rails/pages/reservedwords I''d change the name of the action, and try again to see what occurs. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser wrote in post #967458:> Does the send method exist yet?Yes, it exists. Thanks for the answeres. I''ll try it. Michael, this sounds logical. Forgot about that issue. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
It works! I added this in the routes.rb resources :newsletters do get ''send'', :on => :member end and in the controller I redirected to the page where the newsletters are shown... Thanks a lot everyone! -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Just to be clear. Having action named "send" in a controller is a very bad idea. "send" is a method available for every ruby object and it is quite important method. It is not a good idea to overwrite it. I would name it "deliver". Robert Pankowecki http://robert.pankowecki.pl -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.