Thufir
2008-Jan-18 08:53 UTC
"has_many :through" because "push_with_attributes" is deprecated
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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Thufir
2008-Jan-18 08:58 UTC
Re: "has_many :through" because "push_with_attributes" is deprecated
On Fri, 18 Jan 2008 08:53:23 +0000, Thufir wrote:> I want to use "has_many :through" in line 78 because > "push_with_attributes" is deprecated.Woops, I meant line 73. thanks, Thufir --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thufir
2008-Jan-23 11:20 UTC
Re: "has_many :through" because "push_with_attributes" is deprecated
It may have changed since I posted:
thufir@arrakis ~/strawr $
thufir@arrakis ~/strawr $ cat -n app/controllers/feeds_controller.rb |
head -n 83 | tail -n 16
68
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
thufir@arrakis ~/strawr $
http://code.google.com/p/strawr/source
thanks,
Thufir
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---