LOL yeah, I was so tired when I was working on this earlier this
morning, I just totally overlooked that.
When I change the assignment, I get the "Need controller and action!"
error.
In the View, here is the whole verbage it spits out:
ActionController::RoutingError in Tickets#create
Showing app/views/ticket_mailer/newticket.erb where line #5 raised:
Need controller and action!
Here are the new params:
---------------------------
[4;35;1mSQL (0.1ms) [0m [0mSET NAMES 'utf8' [0m
[4;36;1mSQL (0.1ms) [0m [0;1mSET SQL_AUTO_IS_NULL=0 [0m
Processing TicketsController#create (for 127.0.0.1 at 2010-03-21
14:52:09) [POST]
Parameters: {"ticket"=>{"platform_id"=>"", "title"=>"Testing the
mailer", "app_version"=>"", "app_id"=>"", "category_id"=>"5",
"user_id"=>"2", "os_version"=>"", "status_id"=>"1", "desc"=>"Let's see
what happens.", "customer_id"=>"1",
"notes_attributes"=>{"0"=>{"body"=>"Trying again."}}},
"commit"=>"Create", "action"=>"create",
"authenticity_token"=>"s562boG7oXhkhgeurg4C2mKv/vrAgOg5V/zmZjibMZA=",
"controller"=>"tickets"}
[4;35;1mUser Columns (49.2ms) [0m [0mSHOW FIELDS FROM
`users` [0m
[4;36;1mUser Load (0.7ms) [0m [0;1mSELECT * FROM `users` WHERE
(`users`.`id` = 2) LIMIT 1 [0m
[4;35;1mRole Load (0.4ms) [0m [0mSELECT `roles`.* FROM `roles`
INNER JOIN `assignments` ON `roles`.id = `assignments`.role_id WHERE
((`assignments`.user_id = 2)) [0m
[4;36;1mRole Columns (1.2ms) [0m [0;1mSHOW FIELDS FROM
`roles` [0m
[4;35;1mTicket Columns (1.8ms) [0m [0mSHOW FIELDS FROM
`tickets` [0m
[4;36;1mNote Columns (1.6ms) [0m [0;1mSHOW FIELDS FROM
`notes` [0m
[4;35;1mCustomer Columns (1.6ms) [0m [0mSHOW FIELDS FROM
`customers` [0m
[4;36;1mCustomer Load (0.8ms) [0m [0;1mSELECT * FROM `customers`
WHERE (`customers`.`id` = 1) [0m
ActionView::TemplateError (Need controller and action!) on line #5 of
app/views/ticket_mailer/newticket.erb:
2:
3: A new ticket titled "<%= @ticket.title %>" has been created for you
on the Student Helpdesk Portal.
4:
5: You can view your ticket at <%= link_to @ticket %>.
6:
7: You may submit comments on the ticket to provide questions or
feedback concerning the ticket.
8:
app/views/ticket_mailer/newticket.erb:5
app/controllers/tickets_controller.rb:84:in `create'
Rendered rescues/_trace (147.5ms)
Rendered rescues/_request_and_response (0.5ms)
Rendering rescues/layout (internal_server_error)
-------------------------------------------------
From the sounds of it, it's a routing issue, which seems a bit odd....
On Mar 21, 2:13 pm, Michael Pavling <pavl...@gmail.com> wrote:
> On 21 March 2010 20:03, command0 <justinbrinkerh...@gmail.com> wrote:
>
> > The problem I am having, is when I try to create a new ticket, I get
> > the error:
>
> > NoMethodError (undefined method `customer' for nil:NilClass):
> > app/models/ticket_mailer.rb:7:in `newticket'
> > app/controllers/tickets_controller.rb:84:in `create'
>
> > Which I know simply put is telling me the customer doesn't exist,
> > because customer_id would be nil, so there is no association. But
> > there is.
>
> No, it's telling you that the "ticket" variable (at line 7 of
> ticket_mailer.rb) is nil, and NilClass objects don't have a "customer"
> method.
>
> > class TicketMailer < ActionMailer::Base
> > def newticket(ticket)
> > ticket = @ticket
> > subject 'A new ticket has been created for you'
> > recipients ticket.customer.email
> > from 'helpd...@stevenshenager.edu'
> > sent_on Time.now
> > end
>
> I'd assume the problem is caused by the assignment in the first line
> of the method; I'd guess it's meant to read:
> @ticket = ticket
> ..because as it is, it doesn't make much sense to pass in a ticket
> parameter and then immediately overwrite it with an instance variable.
--
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@googlegroups.com.
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.
No comments:
Post a Comment