similar to: Suggestion: `before_save on: :create` should either work or raise an exception

Displaying 20 results from an estimated 800 matches similar to: "Suggestion: `before_save on: :create` should either work or raise an exception"

2012 Oct 18
3
#asset_url helper method
Just putting this out there before I make a pull request. Is there any interest in an asset_url method as a view helper? It would work by using the config.action_controller.asset_host if it exists and prepending this to the results of asset_path. I have found this necessary when writing html emails and needing a full url path for assets. Since my CDN in the asset_host mirrors my assets in my
2012 Nov 15
2
Suggestion: use `select` values if `pluck` called with no args
I suggest that if you don''t pass any args to ActiveRecord#pluck, it would use the select values. This follows along well with the way other AR::Calculations work. As an extra benefit we would be able to pluck virtual columns. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit
2013 Nov 14
6
validates :boolean_field, presence: true misconceptions
Last night a friend of mine started ranting about validates_presence_of :boolean_field returning not valid when the boolean field is false. I checked the rails issues and this seems to be a pretty common concern about the naming of ''presence'' . Instead of changing the behaviour of the presence validator, I was wondering if maybe the answer to avoid such misconceptions could be
2012 Jul 09
10
attr_accessible on some properties + attr_protected on others makes class 'open-by-default'
(I posted this as a bug in GitHub (https://github.com/rails/rails/issues/7018), but then someone there told me I should post it here, so here it is.) If you set attr_accessible on some properties in an ActiveRecord-descended class, and then attr_protected on others - the class becomes ''default-open'' - if any properties are missed or added later, they will be accessible by
2013 Apr 28
2
[ActiveSupport] Add a "remaining_to" method to date class
Just that: class Date > def remaining_to(date) > if date.acts_like? :date > date - self > end > end > alias :days_to end and then be able to do this: Date.today.remaining_to(Date.parse ''2014-04-02'').days.seconds -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To
2012 Dec 14
1
Re: Digest for rubyonrails-core@googlegroups.com - 4 Messages in 3 Topics
This is a delivery failure notification message indicating that an email you sent could not be delivered. The problem appears to be : -- Recipient email server rejected the message This condition occurred after 1 attempt(s) to deliver over a period of 0 hour(s). If you sent the email to multiple recipients, you will receive one of these messages for each one which failed delivery, otherwise
2013 Jul 22
1
Dependency upon raised error/exception messages.
Hey everyone, first of all, thank you for the tremendous work and effort on making Rails more awesome every day. I''ve brought up this "issue" on Github last Friday. [1] Steve Klabnik told me to bring the discussion here, as it''s more appropriate. The thing is, there is some amount of logic scattered around Rails (and its tests) that depends upon error/exception
2010 Aug 18
11
When after_save isn't after the save....
I have a Production model, which represents a farmer''s crop. After create (via after_save) I call a method that creates one or more Supply models, which represent a week of anticipated product harvest. After each of those are created, a class method gets called that tries to match each new Supply with outstanding orders for the same time period. If a match is made, a transaction (an
2013 Jul 10
4
Decoupling of ActionPack
Hello! Are the plans of splitting ActionPack for several gems (AbstractController, ActionView, etc)? Like https://github.com/rails/rails/pull/7356 ... I.e. I know gems that are needed AbstractController only... And they are forced to require the whole ActionPack... Thanx. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To
2011 Jan 14
4
Rails 3 / RSpec 2 use_transactional_fixtures and after_commit
We''re migrating a Rails 2.3.x application to Rails 3 and RSpec 2.x. In Rails 2.3.x we were using https://github.com/freelancing-god/after_commit to provide after_commit functionality (now provided by Rails 3). The plugin version of after_commit came with some helpers to make testing with `use_transactional_fixtures = true` work. From: https://github.com/freelancing-god/after_commit
2008 Jul 28
1
callback executed like after_save but after transaction
I''m trying to add some code for my ActiveRecord class so that it is executed whenever an object is updated, this code is a seperate process that reads from the same table represented by my model class so when it runs it needs the database to be up to date. In the following situation this is fine: # MyModel def after_save `/usr/local/bin/update_models -i #{self.id}` end # controller
2008 Sep 15
2
not finding activerecord data in worker
Hey guys, Firstly, I''m new to the list and great work with backgroundrb, it''s sweet!!! I''ve just started noticing an issue and i''m wondering if there is a standard fix. The situation is as follows: 1. In my model''s after_save I call my worker asynchronously with the active record object''s id as a parameter (the record that has just
2008 Apr 01
1
Using migration methods in applications.
Is it possible to use methods for migration(create_table, add_column, etc) in applications. I want to make a plugin which uses its own model. In such cases, most plugins seem to use script/generate to generate migration file. But I think if it is possible to make tables directly from plugins, uses doesn''t have to use script/generate or rake. It''ll be easier to use. But I
2006 Nov 17
4
set empty values as null in the database
Le''s say that I have a table called people and the column middle_name is nullable. If the user enters say blank or empty space then in the database it is recorded as empty space. I would like in all my models all empty spaces to be recorded as null. I guess I can write a plugin which will do so for all the models but I''m sure something like that should already be existing.I
2009 Feb 07
5
before_save :strip_whitespace => saves with spaces
i used this private function for removing leading and trailing white spaces from the values.that below function would be called before_save. when i print the value after it strips.it prints string without any spaces.but in the table fields it saves with spaces . waht would be the problem.pls help me class CompanyInfo < ActiveRecord::Base before_save :strip_whitespace def strip_whitespace
2008 Jun 29
3
Working around/with Restful Authentication
I''m using Restful Authentication, and the code to create a user is pretty straight forward - there is a before_save action and a before_create action: before_save :encrypt_password before_create :make_activation_code But for some reason when I try to create a user programmatically in the controller like this: User.new(:email =>
2011 Oct 14
2
before_save :encrypt_password
I am having a problem finding the best way to make a "before_save :encrypt_password" conditional. I have to at times update user model attributes but each time I do this the password is reencrypted because of the above. I need to differentiate between when the user is first logging in and the password does need to be encrypted, and when they are already logged in and the
2008 Jul 10
6
Uppercase all row columns
Hi. I have to convert the contents of all columns to uppercase before creating a row. Is there an easy way to accomplish this so I don''t have to go one column at a time and upcase! it? Thanks. Pepe --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group,
2006 Mar 02
2
How to get mime extension with file_column
Is there a way to get the MIME extension of a file_column field? Here''s what I want to do (look for comment in before_save method): class ProductFile < ActiveRecord::Base belongs_to :product file_column :file_name def before_save self.file_type = # something that returns the MIME type (e.g. image/jpeg) end end TIA
2009 Mar 17
4
Preventing a submitted hash from ActiveRecord DB store
Hi all, I have a multi model form (Project with many tasks) and I want to prevent a task from being saved to the DB if it is empty ie. if there is no i/p for that task from the user. I tried the following class Task < ActiveRecord::Base before_save :check_if_empty ... def check_if_empty self.destroy if description.blank? end but i get this TypeError in ProjectsController#create