I want to use "has_many :through" in line 78 because "push_with_attributes" is deprecated.
How would I go about this, please? I want to create, really, an instance of the Membership class.
thufir@arrakis ~/strawr $ thufir@arrakis ~/strawr $ cat -n app/controllers/feeds_controller.rb | tail -n 46 --verbose ==> standard input <== 69 70 def add_tag 71 72 @feed = Feed.find(params[:id]) 73 @feed.tags.push_with_attributes( 74 Tag.find(params[:tag][:id])) 75 76 if @feed.save 77 flash[:notice] = 'Tag has been added!' 78 end 79 redirect_to :action => 'show', :id => params[:id] 80 end 81 82 def add_some_tags 83 84 85 logger.info "*******************************add_some_tags*******************************" 86 logger.info "*******************************add_some_tags*******************************" 87 logger.info "*******************************add_some_tags*******************************" 88 #logger.info "foo: #{@my_var}" 89 #logger.info "my text" 90 #@my_var = "something" 91 92 93 @feed = Feed.find(params[:id]) 94 95 logger.info "@feed: #{@feed}" 96 97 @unused_tags = 98 Tag.find(:all) - @feed.tags 99 100 if @unused_tags.any? 101 @tags_to_add = @unused_tags.select { |tag| 102 (params['tag'+tag.id.to_s]['checked'] == '1')} 103 @tags_to_add.each { |tag| 104 @feed.tags << Tag.find_or_create_by_tag(params [:which_tag]) unless params[:which_tag].blank? 105 } 106 end 107 108 if @tags_to_add.any? and @feed.save 109 flash[:notice] = 'Tags have been added!' 110 end 111 redirect_to :action => 'show', :id => @feed 112 end 113 114 end thufir@arrakis ~/strawr $
code can be browsed in the "trunk" by clicking on: http://strawr.googlecode.com/svn/trunk/
thanks,
Thufir