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...
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
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.
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...
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".