-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
why getting undefined method? #54
Comments
Does your Message model has an attribute account_name ? If it doesn't or you don't need it perhaps you can add it using attr_accessor :account_name |
the messsage model doesn't have attr_accessor...should I add it? I didn't see it in the README...trying it now! |
hmmm....still not workin...? |
I added attr_accessor :account_name -- in my other app where I used this, I didn't have to do that....what else could be doing this? where is the "account_name" method created (equivalent to brand_name) |
same for me. attr_accessor is a workaround. i't should not be complicated. |
Did you ever get this resolved? I am facing a similar isseu |
This gem does nothing to create the attribute on the model that will receive the autocompleted input. :account_name must be either a database field on the model or a attribute added via attr_accessor |
The example provided is incorrect? In the example, the model (Brand) is different from the controller (Product) and still in the View, we have:
form_for @product do |f|
f.autocomplete_field :brand_name, autocomplete_brand_name_products_path
end
Clearly |
I was having the same issue as above, following along with the readme. The change which made it work was use :name instead of :brand_name (basically exactly what you would use with any other form helper). Maybe the readme needs to be updated? |
Sidk , How is it that is doesn't use :name of upper model ... you use :name already in Master model :/ |
Not sure I understand the question, because you can of course have the same On Thursday, November 27, 2014, AmerPandzo notifications@github.com wrote:
|
I see that you didn't understood. You have form_for @Product do |f| ... PRODUCT .. DO F ... not account or some other model .. .so if i have :name in products , and :name in accounts .. your alleged usage of :name INSIDE OF form_for @Product do |f| ... f.name ... could not give you name of account , it will give you a product name .. not account that we are suppose to get ... |
Oh, I see where the confusion is. You're right that f.name is for @Product. The form is for creating a product and as such the form helper should use either a column in the Product table or an attr_accessor set on the Product model. autocomplete_brand_name_products_path and the rest of the setup done for the Brand model and the welcome controller (in the readme) is where it'll get the brand names from. |
I am getting the following error:
undefined method `account_name' for #Message:0xb5bddb88
I followed the README for my case and have the following:
And in the messages controller for which this form is using:
1 class MessagesController < ApplicationController
2 before_filter :authenticate_user!
3 autocomplete :account, :name, :full => true
The text was updated successfully, but these errors were encountered: