similar to: validates_uniqueness_of :username, :if => !self.new_record?

Displaying 20 results from an estimated 8000 matches similar to: "validates_uniqueness_of :username, :if => !self.new_record?"

2006 Jun 05
2
When adding a record in console, a parameter comes in as null even when I set it
In console, I am trying to create a User but the :account_id does not come in. Console just gives me back :account_id => nil. Obviously I''m trying to set it though. Silly console... But, I can set the account_id column in my controller like so: @user = User.new(params[:user]) @user.account_id = account.id @user.save Here''s what I give to the controller: User.create :name
2006 Jan 02
6
Login_engine - auth against email rather that username?
Hi all, Short of hacking the code apart, is there a method making the login_engine authenticate against email address rather than username? I find that people rarely remember usernames, and would prefer to use email addresses as the identifier. Thanks! Tom
2006 Mar 14
7
Single form w/ relationships: how do I integrate it?
OK - I know this has been asked before, but I cannot find it in the archives. Forgive me if I''m creating more noise than I should. I want to know the easiest way to deal with this scenario: I have articles. I have categories for the articles. On the form where you write an article, there needs to be a free-form field to entire the category. The create() method will build the
2011 Jun 15
1
.new_record? and :_destroy
Rails version 2.3.8 I have a ticket model that has many comments the comments have an attribute called "admin" -- is this a comment added by an administrator the ticket has an attribute called "admin_email_address" I want to validate when saving the ticket and say "if I have a new admin comment, make sure I have an admin_email_address" In my ticket model, the
2006 Jan 03
6
Am I going too far or Rails is just confusing? was {validates_presence_of *_id attributes}
Thanks for the input Blair Zajac and Chris (Nolan and Hall), and for others. If all of you have time, please follow this (the question still relates to the previous posts by me): I have provided full steps to reproduce the symptoms. If it matters, I''m running Ruby 1.8.2, Rails 1.0, and MySQL 5.0.15 on Windows XP Professional. 1. First, the setup MySQL ----- create database testdb;
2007 May 28
2
Rails, respond_to? over anonymous module (extend has_many).
Hello List, I''m trying to generate examples for some list-helpers I have coded which use in my projects. Basically, the Playlist class uses one anonymous module in has_many that acts as helper between acts_as_list and my desired API: class Playlist < ActiveRecord::Base # associations go here has_many :playlist_items, :order => :position, :dependent => :destroy has_many
2007 Jan 21
35
Collection proxies need to be stubbed ?
Hi all ! I just started writing specs on a new project. I would just like to validate that this is the way you would write it. I know about mocks, stubs and expectations. I don''t think this is a problem for me. My question really boils down to: def index @projects = current_user.projects.active end My spec needs to return the proxy, no ? Here''s my code: context "A
2006 Jul 25
2
Authentication design/ideas
Hi all, I''m using acts_as_authenticated for the front end facing part of my site. I have a model called Customer. I now want to protect the admin sides of things. I am thinking of using Ezra''s acl plugin (http://opensvn.csie.org/ezra/rails/plugins/dev/acl_system2/README) for this. My only problem is that I don''t want the model for admin users to be called Customer,
2007 May 17
4
How to mock helpers in view specs ?
Hi all, I am mocking the following Rails view (inside a partial): <%= render :partial => "forums/forum", :collection => forum_category.forums.readable_by(current_user? ? current_user : nil) %> My spec fails with the following message: 1) ActionView::TemplateError in ''forum_categories/index (anonymous user) should only render forums accessible to anonymous
2006 Jul 26
2
ResponseLogger Plugin
http://www.agilewebdevelopment.com/plugins/responselogger From the README: Ever wondered what exactly Rails returned in an RJS response ? Here''s your chance to see it: ===> text/javascript (49 bytes) Element.replace(''target'', ''<em>It works!</em>''); <=== == ResponseLogger Logging the response value is easy. Simply install
2006 Jul 20
5
Apache 2.2, Mongrel and #caches_page
Hi ! I''m no expect when it comes time to configure Apache. I just enabled page caching in my Rails app, and am now looking at making Apache serve the cached files instead of calling into Rails. I know Mongrel is able to serve cached files if it finds them, but I''d like Apache to do it. Looking at .htaccess, there is this section: RewriteEngine On RewriteRule ^$ index.html
2006 Mar 24
8
[OT] Does Net::HTTP support secure connections ?
Hi ! I''m trying to connect to an https URL, but it seems it doesn''t work. Has anyone successfully connected from Ruby to an HTTPS server ? Thanks ! -- Fran?ois Beausoleil http://blog.teksol.info/
2006 Feb 24
6
when i save, rails doesnt update the model instance with the id of the new record
Hi everybody, Im using sqlserver (sqlserver adapter). I think that is some bug. any idea? -- _________ Noel R. Morais
2007 Dec 19
2
Nested partials losing the view context ?
Hi all ! I can''t seem to make a simple thing work... The code is here: http://pastie.caboo.se/130660 Essentially, that''s a form with a couple of partials. The backtrace is included in the pastie. It looks like the context for the current view is lost when a partial is rendered. In _series.html.erb:2, I use "series" to get the name. This is the parameter I
2006 Mar 07
5
subversion help!
I created a subversion repository on my new vps and i''m trying to setup my rails app there. However i keep getting this error: subversion/libsvn_subr/io.c:2516: (apr_err=13) svn: Can''t create directory ''/home/svnadmin/rapleaf/db/transactions/0-1.txn'': Permission denied How do i fix this? I know others have had this before, so i would appreciate some help.
2006 Apr 16
5
Granular model validation based around controller actions?
How can I achieve granular control over the validation for different controllers? I create users from an administration controller, but I don''t want to fill in all their information fields, just have their name and email address. When they accept the invitation, I want to implement validation on the other fields. I have looked at using :on => :update, but I would have to make the
2006 Mar 30
9
script/console not working after Rails 1.1 upgrade
Whenever I do script/console I get an error message: Loading development enviroment. c:/ruby/lib/ruby/1.8/irb/init.rb:151: in ''parse_opts'' : undefined method ''upcase'' for nil:NilClass (NoMethodError) from c:/ruby/lib/ruby/1.8/irb/init.rb: in ''setup'' from c:/ruby/lib/ruby/1.8/irb/init.rb:54: in ''start'' from c:/ruby/bin/irb:13
2009 May 25
4
after_create and has_one association bug?
Hello, I''ve come across an issue that I''m sure is a bug when using after_create with a has_one association, but I''m not 100% certain if I''m missing something. This is pretty much exactly the code I''m using. Two simple classes (Account and Contact) and I create the contact after I create an account (via after_create). I''m not passing in a
2006 Aug 25
10
SVN security hole explained
Hi all, If you are using Pound / Pen or another load balancer, I believe you should read this: http://blog.teksol.info/articles/2006/08/25/subversion-metadata-exposure-on-mongrel My article refers to Dan Benjamin''s http://hivelogic.com/articles/2006/04/30/preventing_svn_exposure My point is that even though we are preventing Apache from serving anything except a select few file
2006 May 03
8
Subversion and tmp directory in Rails 1.1 project
Hello everyone! I''m thinking of the right way to store tmp/ directory of Rails 1.1 project in Subversion. It has cache, session and sockets subdirectories. To me, it looks good to have svn delete tmp/* svn propset svn:ignore "*" tmp So it will ignore all directories and files in tmp/. Even if you create sessions/ and put some files in it, tmp/ content is still ignored. But