hi all
when i m trying to save my tags.this error s cmng…cn anybody
help me to how to save the array
error depicting = undefined method `save’ for []:Array
hi all
when i m trying to save my tags.this error s cmng…cn anybody
help me to how to save the array
error depicting = undefined method `save’ for []:Array
it would be better if you showed some code about how this array gets
created and used…
generally - and assuming the array contains un-saved ActiceRecord
Objects and not just params or something:
@tags.map! {|t| t.save }
actually i m gettng this error while using act as taggable on steriods
plugin
def create
@article = Article.new(params[:article])
@article=Article.find_tagged_with(params[:tag_list])
@article.save
okay now it’s clear…
Article.find_tagged_with(params[:tag_list]) will return an array of
article objects (even if there is just one match in the database)
Then you call save on this array. Which of course will not work.
You are also overriding the new created @article with the ones
retrieved from the DB … why? or is this a typo and the articles you
get from the DB should be @articleS ? Like, create a new article, and
find related ones by tag to show them after the new article was
created?!?
def create
@article = Article.new(params[:article])
@related_articles= Article.find_tagged_with(params[:tag_list])
@article.save
end
That should work, if you want that.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs