submit button has no effect on the db

I think that the line with "@feed.tags << Tag.find_or_create_by_tag(params
[:which_tag]) unless params[:which_tag].blank?" isn't correctly saving
data.

What I want to happen is that the user places a checkmark on a "tag",
then clicks the button. That adds a record to the "memberships" table
with three fields:

feed_id
tag_id
membership_id

However, the db remains unchanged :frowning:

An excerpt from
http://strawr.googlecode.com/svn/trunk/app/controllers/feeds_controller.rb
with the relevant method:

thufir@arrakis ~/strawr $
thufir@arrakis ~/strawr $ tail app/controllers/feeds_controller.rb -n 34

def add_some_tags

logger.info
"*******************************add_some_tags*******************************"
logger.info
"*******************************add_some_tags*******************************"
logger.info
"*******************************add_some_tags*******************************"
#logger.info "foo: #{@my_var}"
#logger.info "my text"
#@my_var = "something"

  @feed = Feed.find(params[:id])

  logger.info "@feed: #{@feed}"

  @unused_tags =
    Tag.find(:all) - @feed.tags

  if @unused_tags.any?
    @tags_to_add = @unused_tags.select { |tag|
      (params['tag'+tag.id.to_s]['checked'] == '1')}
    @tags_to_add.each { |tag|
        @feed.tags << Tag.find_or_create_by_tag(params[:which_tag])
unless params[:which_tag].blank?
     }
  end

  if @tags_to_add.any? and @feed.save
    flash[:notice] = 'Tags have been added!'
  end
  redirect_to :action => 'show', :id => @feed
end

end
thufir@arrakis ~/strawr $

thanks,

Thufir

Poking around in the code, I notice a few things.

1) feed has many tags through memberships, and membership.rb has some
validations, perhaps these are failing.

2) In your controller code, in the method above you are using
push_with_attributes, which is deprecated, you seem to be mixing hmt
with the obsolete push_with_attributes.

[...]

Poking around in the code, I notice a few things.

1) feed has many tags through memberships, and membership.rb has some
validations, perhaps these are failing.

Yes, I was considering this and dropping the validations; I'll do
that.

2) In your controller code, in the method above you are using
push_with_attributes, which is deprecated, you seem to be mixing hmt
with the obsolete push_with_attributes.

I want to fix this regardless. I found:

"push_with_attributes and concat_with_attributes on a HABTM
association
are deprecated. Use has_many :through with a join model instead. "

http://groups.google.com/group/ror2ru/msg/d05523f76b396787

But will continue to research this. Ironically, I'm using
has_many :through with a join model already.

-Thufir