When I go to delete a post I keep receiving an error that says
undefined method `destroy’ for “Tech”:String
The “tech” part of the posts varies with whatever the tag is of the post I am trying to delete. I am not sure what the problem is. I am using acts_as_taggable_on if that has anything to do with it.
This is my destroy method in my posts controller:
def destroy
@post = Post.find(params[:id])
@post.destroy
respond_to do |format|
format.html { redirect_to(root_path) }
format.xml { head :ok }
format.json { head :ok }
end
end
The delete button in my post show:
<%= button_to 'Delete', @post, :method => :delete, :confirm => "Are you sure?" %>
Tags are saved in the database as a string.
It’s impossible to give you an answer to fix your problem, because you are giving no code and no examples.
Nonetheless that error means you are calling the destroy method on a string, and strings in Ruby do not have a destroy method defined.
Check where are you calling destroy, because it seems you are doing it in some function that returns a string (a tag name in your case). You must do it on an object that is an instance of the Tag class.