similar to: delete_if does not work on associations

Displaying 20 results from an estimated 400 matches similar to: "delete_if does not work on associations"

2006 Sep 25
2
@article.article_groups.delete_if... Dosn't work!
If I try: @article.article_groups.delete_if {|x| x.group_id == x.group_id } It does nothing. If I try: articletmp.article_groups.each{ |x| @article.article_groups.delete(y) } It deletes some of the groups. @article.article_groups.clear works. Why dosn''t the to first examples work as expected?? Do I have to put groups I don''t want to
2006 May 26
4
shouldn''t this work? - session[:array_of_objects].delete_if {|x| x.id == params[:id]}
I am saving an array of active record objects (college courses) in the session as session[:course_list]. This is the cart for a registration controller. If a student chooses to delete the course from the list I get the :id as params[:id]. However if I do session[:course_list].delete_if {|x| x.id ==params[:id]} does not work. session[:course_list].delete_at(idx) works. Ocourse to do this I have
2006 Aug 08
12
delete_if doesn''t work for has_and_belongs_to_many
I''m using Rails-1.1.4 with Ruby-1.8.4 So let''s say I have 2 model classes: class Item has_and_belongs_to_many :things end class Thing has_and_belongs_to_many :items end i = Item.new i.things << Thing.new( :value => "Something").save i.things << Thing.new( :value => "Something Else" ).save i.save Fine, now I have two records in the
2006 Nov 04
0
@article.article_groups.delete_if... Dosn''t work!
If I try: @article.article_groups.delete_if {|x| x.group_id == x.group_id } It does nothing. If I try: articletmp.article_groups.each{ |x| @article.article_groups.delete(y) } It deletes some of the groups. @article.article_groups.clear works. Why dosn''t the to first examples work as expected?? Do I have to put groups I don''t want to
2013 Sep 17
4
Rails 4 deprecation of in-place edit methods for collection associations
Hi everyone! For those of you who are not noticed the in-place edit method for collection associations are broken in the current rails release - 4.0.0, and here''s what is cooking in the rails master https://github.com/rails/rails/commit/1a40be02113287d9a003f8224e91b9f623857f4b and this https://github.com/rails/rails/pull/12227 In short: it looks like things like has_many.reject!{},
2006 Jan 07
3
user engine question
I''ve created an array of hashes in UserController#initialize to describe a menu: @menu_array = [ {:menu => ''home'', :controller => ''home'', :action => ''send_home''}, {:menu => ''user list'', :action => ''list''}, {:menu => ''login'', :controller =>
2007 Jan 06
3
speeding up pagination
I need help to optimize a query (sort of ...) if params[:debit] == "on" @schools = School.find(:all, :conditions => ["name like ?", "%#{params[:search]}%"], :order => ''name'') @schools.delete_if { |s| s.debit <= 0 } @school_pages = Paginator.new self, @schools.length, 20 The problem here is that
2017 May 17
1
browsing problem with minimum protocol SMB2
I have a classic NT4 domain with the PDC also the wins server. With the recent ransomware problem, we're trying to remove SMB1 and below protocols. However when I do this, the browse list is gone. Hosts can access properly the shares, but they have to know exactly \\machine\share in order to to connect. The same thing from a linux client: smbclient -L {PDC} -m SMB2 Domain=[{MYDOMAIN}]
2011 Feb 28
1
(2.3.5) removing validations
Today I tried to remove (actually overwrite) a validation from a model, from within a plugin. This was the original validation: validates_length_of :login, :maximum => 30 This was the only code I could come up with to replace it: def self.included(base) base.class_eval do @validate_callbacks.delete_if { |callback| begin # Sorry, only way to remove
2006 May 23
6
How to list all models of an application?!?
How can I get a list of all model classes in the domain of a Rails application (all models, both in "app/models" and in components/somedir/model.rb)? Thanx in advance for your precious help! Edoardo "Dado" Marcora
2008 Mar 26
2
Missing Method defined in controllers/application.rb
I have this in my controllers/application.rb: class ApplicationController < ActionController::Base ... def datebalk! # set regexp for datebalks generated attributes c = /.*__dteblk/ # Remove datebalks generated attributes from params hash delete_if { |k, v| c =~ k.to_s } end ... end When I call this from client_controllers.rb in this fashion: # need this to strip
2016 Jan 19
2
Samba 4 and Windows 10 Problem.
For my home server i did it like this. Share \\server\backups [backups] path = /media/sambashares/backups read only = No by default everybody had full control on the share. Rights on the folder are 777 In this share/folder i have proctect folders. Like : /media/sambashares/backups/louis /media/sambashares/backups/mywife I created a linux user with the same name as i use in
2006 Jan 28
3
DRY conflict with "Updated at" "Created at" "Deleted at" in view
Hi all, Are there any helpers or so for listview routines that suppres the three above mentioned columns? I''m currently exploring something like the code below. But it feels like I''m doing Rails'' work. # just for test purposes <div id="debug"> <% for col in Product.columns.map %> <%= col.name %> - <%= col.type %><br/> <%
2006 Jan 23
5
Bibtex database design
I am working a Bibtex database for my school using Rails and I need some idea on how to manage the bibtex types. I crated an Author and Publications model and put has_and_belongs_to_many relationship between them. The user model basically is like this: class User < ActiveRecord::Base has_and_belongs_to_many :publications end The Publication model has all the Bibtex fields
2009 Feb 09
2
dynamic constant assignment
I have a constant set up like that : ALL_LOCALES => {"it"=>"Italian", "fr"=>"Français", "de"=>"Deutsch", "en- GB"=>"English (UK)", "es"=>"Español (España)", "pt-PT"=>"Português", "pl"=>"Polski", "en-US"=>"English
2006 Dec 17
3
Trimming a collection of AR objects?
I have a collection of acts_as_ferret search results that I need to trim based on an attribute. I''ve been trying to iterate through the collection but haven''t been able to make this work. Here is what I have tried unsuccessfully: @people.each {|person| person.clear if person.privacy_type == "private"} Unfortunately Class Person does not respond to clear since it is
2003 Aug 26
0
files between w2k domains...
Hi, I have a Mandrake 8.2 server with samba 2.2.5 installed. My server has ftp and the files some users upload I move them to another structure, this structure is shared via Samba with other users. I am in a W2k Domain.(We are in the process to migrate to linux). So, I have some users that move the files uploaded to their servers. A few days ago, a user reported me he couldn?t see the files in
2006 Apr 17
5
Finding out updated fields
Hi, When we update a record via an update form, is there an easy way to find out the fields that have been changed. If the update is successful, i want to display: The following fields have been changed: field-name = new-value ... Thanks, Lantis. -- Posted via http://www.ruby-forum.com/.
2007 Dec 28
11
LIKE clause in rails
Hello, I am trying to achieve a search functionality in the following manner i have an table called people which has first_name,last_name,etc... After the user form to search people is submitted i get the params hash as params[:persons]={"first_name"=> "%John%","last_name"=>"%Stevens%"} NOTE : I have changed the params hash to include the %. Now
2016 Jan 19
0
Samba 4 and Windows 10 Problem.
Hi Louis I'll try your configuration too.. Thanks.  RODRIGO YOSHIOKA Em Terça-feira, 19 de Janeiro de 2016 8:37, L. P. H. van Belle <belle at bazuin.nl> escreveu: For my home server i did it like this. Share \\server\backups [backups]     path = /media/sambashares/backups     read only = No by default everybody had full control on the share. Rights on the folder are 777