similar to: help with validations

Displaying 20 results from an estimated 40000 matches similar to: "help with validations"

2013 May 19
5
update_attributes() for a single column
I was just faced with a strange ROLLBACK exception when attempting to execute this code: $ rails console user = User.first User Load (1.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 => #<User id: 1, name: "Michael Hartl", email: "foo-+RB1Aph5k6s@public.gmane.org", created_at: "2013-05-12
2012 Mar 13
4
minitest validations - is there a cleaner way?
i am trying out minitest, but need some advice on a clean way to test validations. I setup my testing to use minitest by following the following railscast plus i added miniskirt for Factories. http://railscasts.com/episodes/327-minitest-with-rails everything works well, but there has to be a cleaner way of testing failed validations. would i be better off using something besides
2010 Aug 18
2
auth logic - password confirmation
Hi, newbie here. :) i have this form on a test rails app: <% form_for @user do |f| %> <%= f.error_messages %> <p> <%= f.label :username %><br /> <%= f.text_field :username %> </p> <p> <%= f.label :email %><br /> <%= f.text_field :email %> </p> <p> <%= f.label :password %><br
2010 Nov 28
2
Dynamic find_by method returning nil in a class method
I have a user Model with a class method that I am using to do some authentication basically something like this class User < ActiveRecord::Base attr_accessor :password attr_accessible :first_name, :last_name, :email, :birth_date, :sex, :password, :password_confirmation email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i validates :first_name,
2012 May 13
4
undefined method `key?' for nil:NilClass,bcrypt-ruby,has_secure_password
I''m going through DHH''s Agile Web Development with Rails for Rails 3.1. In chapter 14 they create a Users sign-in model/view/controller using the has_secure_password method. My user.rb file looks like this class User < ActiveRecord::Base attr_accessible :name, :password_digest, :password, :password_confirmation validates :name, presence: true, uniqueness:
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/. --
2010 Jan 04
2
to_parm and how it can be used in a helper
is there a way to pass the data returned by the to_parm function in a helper? i followed the info provided at http://www.jroller.com/obie/entry/seo_optimization_of_urls_in and am able to successfully get the correct urls, now i want to be able to get the same (id-whatever) text and pass it to a helper function for further processing. Any ideas as to how this can be achieved? -- Posted via
2011 Jun 16
2
Authlogic: Trying to login in my Cucumber test - Authlogic::Session::Activation::NotActivatedError
In a Cucumber step definition, I''m trying to login, but I keep getting this error: You must activate the Authlogic::Session::Base.controller with a controller object before creating objects (Authlogic::Session::Activation::NotActivatedError) My code: Given /^I am the logged in (.+) "(.+)"$/ do |role, login| user = User.create!( :login => login, :password =>
2009 Dec 23
8
Where did this value in a form come from?
Newb here. I have a form and a value that is being displayed ... and I have no idea where the value came from. I have done a <%= debugger; '''' %> in the form and, indeed, the debugger stops at the statement. I have tried to trace through the code to see where the value came from ... and I gave up. So ... what in Rails initializes the fields of a form? -- Posted via
2012 Nov 08
1
validates_uniqueness_of(*attr_names) w scope not working in unit test
Rails 3.2.8 Very strange , it works in dv mode console , but not in a unit test class User < ActiveRecord::Base belongs_to :subdomain validates_uniqueness_of :email, :scope => :subdomain_id class UserTest < ActiveSupport::TestCase def initialize_user @booboo = FactoryGirl.create(:subdomain, name: "booboo") @coocoo = FactoryGirl.create(:subdomain, name:
2010 Sep 25
3
Factory_girl association with specific values
Hope this should be simple: I have a User model and a Role model. Factories for each. When I create a User using FG, I want to assign a specific role. Cant seem to figure out how to do this, getting errors like: uninitialized constant SysadminRole for doing things this way: Factory.define :user do |u| u.practice_id { |a| a.association(:practice).id } u.password ''password1''
2011 Jul 14
10
Devise confusing routes
I had a similar problem yesterday. I would go to the root of my site and I would get a Too Many Redirects message. It seems like there was an infinite loop. After struggling for over an hour yesterday late at night, it seemed like I fixed it. But now, when I want to create a New User, it''s redirecting me to the Sign In screen. Seems like I didn''t fix the problem completely. I
2010 Jun 07
3
Model validation giving problem
Hi, I have a member registration form which takes a "Name", "Login", "Password", "Confirm Password" and "Location". In the user model I have added the validation validate_uniqueness_of :login, validate_presence_of :password, :name, :confirm_password. When the member tries to register every thing working fine. I am using same form for user to edit
2012 Sep 17
1
require current_password to update user information
Rails newbie here, I have been stuck on this for two days and can''t figure out why its not working. I want users to confirm/verify themselves by entering their current/old password before any information is updated. This is what My user_controller update action looks like I''m currently using rails 3.2 with the basic has_secured_password authentication that comes with it. def
2012 Jan 18
4
Adding a custom select to omniauth register form
Hi, I''m creating a rails app using omniauth 1.0.1 on Rails 3.1.3 and ruby 1.9.2 I''m having trouble adding a select field that populates from a class constant in my user model. Here''s my model: class User < ActiveRecord::Base ROLES = ["Customer","Service Supplier"] has_many :leads validates_presence_of :role def
2012 May 12
12
before_save messing up
#user.rb ------> Model class User < ActiveRecord::Base attr_accessible :email, :name, :password, :password_confirmation has_secure_password before_save :create_remember_token . . . . . . . private def create_remember_token self.remember_token = SecureRandom.urlsafe_base64 end end #sessions_controller.rb ------->
2011 Jan 06
4
Not able to insert value in rails console
I am using authlogic for authentication in rails 3.0.3 with ruby 1.9.2 Using activerecord-sqlserver-adapter (3.0.5) windows with sqlserver database when i create user details in rails console, i am getting below error, >User.create(:login=>''test'',:password=>''test123'',:password_confirmation=>''test123'')
2011 Dec 13
3
Validates presence
Hi everyone, I just need a quick help :) What is the best way to write some code in :presence option? I have a Question model and one of the fields is question_type: - example question - static question Each question has alternatives, and each of them has scores What I want is to validate the presence of :score, but when its only on the static question. I dont want to validate the presence
2010 Jan 26
2
accepts_nested_attributes_for :has_many :through => 'bug?'
Hey guys & ladies! I''ve got the following relationship which i''m trying to get accepts_nested_attributes to work with. But when i submit my form, it looks as if its expecting a Company object, rather than an array of companies. which really doesn''t make sense considering its a has_many :relationship. So what i''m after, is a way to
2010 Jan 12
8
tips on how to write a controller test for models associated with currently logged in user
I have a controller test here: http://gist.github.com/275616, which works fine when account is an independent model, however I want: an account to be a property of user, ( and created and associated when a user is) when the user goes to /account/edit it should on edit the account of the logged in user - I can make rails do this, but I''m utterly baffled how I should alter this test to