search for: full_messages

Displaying 20 results from an estimated 80 matches for "full_messages".

2007 Jun 24
6
mocking errors
What is the correct way to mock out the errors on a Rails model? I''m assuming i need to say @mock_thing = mock_model(Thing) @mock_thing_errors = mock("errors") @mock_thing_errors.should_receive(:full_messages).and_return("An error") @mock_thing.should_receive(:errors).and_return(@mock_thing_errors) Just wanted to check the best practice on this kind of thing and how other people handle it. Cheers, David
2009 Oct 09
0
ActiveRecord::Errors#full_messages changes in 2.3.4
After upgrading our application from Rails 2.3.2 to 2.3.4 all our error messages appeared as "{{attribute}} {{message}}" (literally). Since we noticed this problem short before a release and hadn''t enough time to look deeper into it we fixed it by using the "old" full_messages method that was present in 2.3.2 So today I started reading up on what exactly has changed, but currently I''ve hit the wall and have no idea what it was. I''ve read a couple of bug reports and looked at the commits but I couldn''t make anything out of it. Our applications...
2009 Aug 01
23
Hi doubt in unit testing
def test_check_for_validity post=County.new(:name=>"myname",:description=>"mydesc") assert post.save end above is the method and when i run unit test it is saying as 1) Failure: test_check_for_validity(CountyTest) [/test/unit/county_test.rb:10]: <false> is not true. what does it say i cannot under stand please help -- Karthik.k Mobile -
2009 Nov 26
9
ActionView::TemplateError (can't convert ActiveRecord::Error into String)
I cannot work out why this error is appearing. ActionView::TemplateError (can''t convert ActiveRecord::Error into String) on line #3 of app/views/button/_show_enquiry.html.erb: 1: <h1>Send us a message</h1> 2: <% remote_form_for :enquiry, :url => {:action => ''send_mail''} do | f| %> 3: <%= error_messages_for ''enquiry'',
2006 Feb 24
2
Shortcircuit evaluations
...ht I''d post here. I have the following validator validates_each :thumbnail, :regular do |record, attribute, value| unless value.nil? && value.valid? record.errors.add( attribute, value.errors.full_messages[0]) end end I''m getting a ''nil object when you didn''t expect it error'' because the condition is evaluating value.valid?. I was under the impression that if the first condition (v...
2008 Feb 27
8
ActiveRecord validation messages not I18N-friendly and enforces grammar
ActiveRecord validation messages are currently not I18N-friendly. Specifically, I''m referring to the fact that it enforces a certain grammar, namely the beginning of the message must consist of the field name. For example: validates_presence_of :name, :message => "can''t be blank." ...generates the message "Name can''t be blank". This grammar
2006 Feb 22
3
Unit test failure - nil object?
I''m following instructions in the Agile book, page 146 for testing an object update to the database. Here''s my code: def test_update assert_equal "jack@smiths.com", @user.email @user.email = "jack@smiths.org" assert @user.save, @user.errors.full_messages.join("; ") @user.reload assert_equal @user.email, "lindsay.boyd@ntlworld.co.uk" end An error is generated when the save method is called. I''m guessing the code is OK and the problem lies with the database? Here''s the error text: 1) Error: test_u...
2006 Feb 28
1
adding to errors in controller?
...rams[:id]) @product.attributes = params[:product] if params[:main_image] image = Image.new params[:main_image] if image.save @product.main_image.destroy if @product.main_image @product.main_image = image else @product.errors.add_to_base(image.errors.full_messages.join(", ")) end end if @product.errors.empty? and @product.save flash[:notice] = "Product was successfully updated" redirect_to :action => "show", :id => @product else render :action => ''edit'' end en...
2006 Oct 08
9
Organizing tests and mocha expectations
..."should render edit form" do setup_controller @client = mock Client.expects(:find).with("1").returns(@client) @client.expects(:attributes=).with("attributes") @client.expects(:save!).raises(ActiveRecord::RecordInvalid.new(stub(:errors => stub(:full_messages => [])))) @controller.expects(:render).with() @controller.expects(:render).with(:action => "edit")\ put :update, :id => 1, :client => "attributes" end end Now, to fit well with RSpec''s methodology, I''d like to have a setup method wh...
2010 Sep 23
7
errors.add, setting the whole message
Hi all. I have an attribute, job_role_id_short, that is being set in a form. This field has a custom validation on it, which does this if it fails: self.errors.add(:job_role_id_short, "cannot be blank") I want to add the error onto the attribute, so that the form builder will wrap the field in a fieldWithErrors div. However, the error it generates says "Job Role Short cannot
2006 Jul 20
7
How do you use :message with validation?
If I do validates_uniqueness_of :name, :message => "It''s not uniqueeee!!!" then how do I have it display that message when the check fails? -Ben Lisbakken -- Posted via http://www.ruby-forum.com/.
2009 Feb 05
6
get # of errors in error_messages_for
hi everyone here i go again, i have problem we error message validation here is the sample of my code: error_messages_for :user, :header_message => ''X errors, please find red mark'', :message => ''Following errors were found:'' the problem is that how where going to get the value "X errors" or the number of errors if they have when the is
2011 Oct 25
1
Customizing errors
...AR model that has an :author_name attribute. Now if a validation goes wrong, I would like the message to say: "Name of author can''t be blank" as opposed to "author name can''t be blank". I have tried looking into the Rails Guides for I18n #5 but it seems error.full_messages does not call human_attribute_name on the attribute before rendering the message. So I created a workaround which I have shared http://igbanam.wordpress.com/2011/10/25/customizing-error-messages-in-rails/ Comments and constructive criticisms please. -- You received this message because you are s...
2007 May 09
1
Custom validation error messages.
...ame, :message => ''^The surname supplied is not valid.'' Whereby the use of the ^ says that error message should be output as is, without any prefixing, but just without the ^. Are there any other cleaner alternatives than this plugin? What if (and most likely it may) the Rails full_messages changes and things then break? BTW full_messages is overriden by said plugin. I know it''s probably being picky of me, and the plugin is almost there and a clean enough solution. Thought I''d ask. Cheers, Diego --~--~---------~--~----~------------~-------~--~----~ You received t...
2011 Jul 27
2
rails 3.0.9 usability problem
If there is an error with the submitted password on a form, then both the password and password confirmation text fields should be highlighted in red. The default seems to be to highlight only the password field. Any suggestions on how to correct that? Because rails magically handles the highlighting, I''m not sure how to intercept that. -- Posted via http://www.ruby-forum.com/. --
2012 Feb 14
6
SMTP problem.
Hey all, well I am trying to send emails to newly created users but I have a problem. In the rails log it states that the email has been sent but the email is never actually received so obviously there is a problem. I have noticed one in particular and I don''t understand how to fix it. Once I create the user I get the following error message: Net::SMTPAuthenticationError (535-5.7.1
2006 Sep 29
7
help needed in UNIT Testing
hi guys, I needed help in Unit test. i just try to save new data intomy test database. but save method does not works for me. the result shows here def test_new_avail avail = Avail.new(:vendor_id => 1, :last_mod_by => ''Murali'', :updated_at => ''2006-08-17 13:14:59) assert avail.valid? assert avail.save end
2009 Jun 11
8
before_create return value breaking object.save: rails bug?
...e last statement in it evaluated to false), then the saving gets blocked - i can see the db transaction rolling back. However, this doesn''t affect the results of calling .valid? on the object, so i get this situation: new_user.valid? => true new_user.save => false new_user.errors.full_messages => [] This has caused me a considerable amount of beard-tugging to track this down. Now, i was under the impression that before_create doesn''t care what''s returned by the method it calls, and for my other before_save callbacks it doesn''t seem to make any difference...
2012 Sep 25
3
Proposal for a new ActiveModel::Errors structure
...) end alias_method_chain :add, :save_names end end This solution is far from perfect, but it''s relatively simple and so far works for us. The best solution would be to actually build a structure similar to GitHub response - from that structure it would be trivial to build #full_messages and similar methods and it would provide a lot of additional info which would be extremely useful for creating APIs. Cheers, Szymon -- 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 https...
2009 Jul 21
2
About Error handler
Hi I am new to ruby on rails I need to know one thing Is there any way to externalize all the error messages in one file and access -- Karthik.k Mobile - +91-9894991640