Currently, in my request model I have:
belongs_to :requestor, :class_name => 'User'
So the requestor is the current_user.
Problem is when the current_user
clicks the create button to submit a form for a request, all of the attributes get updated to the database that are in the form.
But since requestor_id
is not a value to fill out in the form, that brings back a value of null in the database when the new request record is created.
What I want is an integer (which equates to the primary key of the Users table) updated in the requestor_id
column in the request table when the user clicks the create button.
So I thought that maybe adding a requestor_id
as a symbol in the params for the create action would solve that:
def create_common
@a = Request.new
b = @a.requestor_id
@resource = yield params[:contact + "#{b}".to_sym]
self.resource = @resource
But instead it returns the following error:
interning empty string
Thanks for any suggestions.
I kept getting this error. I traced it to very simple code and reproduced in the console with this:
ruby-1.8.7-p174 :084 > a = 'fred'
=> "fred"
ruby-1.8.7-p174 :085 > a.to_sym
=> :fred
ruby-1.8.7-p174 :086 > a = ''
=> ""
ruby-1.8.7-p174 :087 > a.to_sym
ArgumentError: interning empty string
from (irb):87:in `to_sym'
from (irb):87
Can you not just pass the Request the current_user when you create it?
@req = Request.new(:requestor => current_user)
I am not quite sure what the yield params statement is meant to be doing,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With