Displaying 20 results from an estimated 10000 matches similar to: "Validating Uniqueness From Two Database Tables?"
2007 Sep 02
2
problem validating uniqueness
I have validates_uniqueness_of :name in my model which works fine when
creating a record but doesn''t work when I edit the record. In other
words it won''t let me create a record with the same name but I can go
in after and update the field without a problem. Why would this
happen? -Mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you
2005 Oct 21
4
Validate uniqueness on two columns
I would like to validate the uniqueness of two columns together. I have last
and first names as separate columns. What is the Rails Way to do this?
Thanks,
Jared Nuzzolillo
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails
2009 Sep 12
3
Cannot get my password to validate
Hello,
I am working through the railsspace tutorrial, and i''ve noticed that
the password validation is no longer working.
I can get screen_name and email to validate, but for some reason, the
password field is ignored...
here''s what i have so far:
within user.rb file
PASSWORD_MIN_LENGTH = 4
PASSWORD_MAX_LENGTH = 40
validates_length_of :password, :within =>
2012 Mar 14
0
Validating field uniqueness via Ajax call with appropriate message in Rails 3
Hello all,
I am trying to do a Rails + AJAX call validation to check for the
uniqueness of a field, by crawling the back end DB and return an
appropriate message based on the result.
I am on Rails 3.0.11.
Your kind inputs on what could be the best way to tackle this would be
of real help.
Is there a ruby gem / js plugin / jquery plugin that I can make use of?
Any blogs links implementing the
2006 Feb 17
2
validate uniqueness of two fields
I have Proposals and Members and Members can vote for a proposal only once.
So, I have "Vote belongs_to :member, :proposal", but to make sure a member only votes
once, I want to make sure that there isn''t a vote in the db with that member_id and
proposal_id. I can just put the appropriate find in a vote.valid? but I wanted to make
sure I wasn''t missing a nice rails
2010 Jul 31
4
Exception: can't dup Symbol
Hey everybody,
I''m trying to test a little piece of code I wrote, and I get the
following error:
Exception: can''t dup Symbol
It happens in the following line: try_to_login @valid_user, :remember_me
=> "1",
where the function try_to_login is:
def try_to_login(user, options = {})
user_hash = {:screen_name => user.screen_name, :password =>
user.password}
2006 Feb 06
1
Check, and display, AIM status on rails page
Thought I''d post this in case it''s of use to anyone. Maybe even a recipe?
It''s just some simple helpers to show AIM status on a webpage.
I searched before coding it, and didn''t find anything similar.
Maybe that''s because it was so simple :)
These methods belong in a helper (such as app/helpers/application_helper.rb)
# begin AIM helper methods
def
2006 Apr 14
1
Validating Existing Models
I''ve got a user object which has quite a few attributes mapped to the
database. As of right now I''ve got some validations in the model like:
validates_presence_of :password, :message => "You must specify a valid
password."
validates_confirmation_of :password, :message => "Password doesn''t match
the confirmation."
validates_presence_of
2006 Feb 22
15
Fixtures and Relationships
In my daily development, I migrate back and forth between versions, and
often do: rake load_fixtures...
... in order to populate my development database with fun data.
Now, with any HABTM relationship, there are failures, as there is no way to
say "which" fixtures to load first.
Within an actual functional or unit test case, you could simply load them in
the proper order, but
2010 Mar 21
0
Validates uniqueness scope
In a Rails 2.x validation to check if the name of some model is unique
within a some category, I would use:
`validates_uniqueness_of :name, :scope => :category_id`
In Rails 3, this is replaced with:
`validates :name, :uniqueness => true`
However, I can''t seem to find a method of defining the uniqueness''
scope. Am I missing something?
Thanks,
Angelo
--
You received
2006 Jun 29
0
How to validate uniqueness only if value exists
I''m looking for the best way to use validation to confirm that an
optional field (hostname) is unique only if a value is entered in the
form.
I was originally following the path shown in Agile Web Development with
Rails first edition, page 66, to define the "validate" method, but
didn''t have a clue how to include a uniqueness test there. Right now, I
have the
2010 Aug 14
10
Redirecting after logging in
Hey everybody,
I''m trying to make an example of a small networking site, and when I log
in a user, it should redirect and show his profile, but I get the
following error:
NoMethodError in User#index
Showing app/views/user/index.html.erb where line #5 raised:
undefined method `screen_name'' for nil:NilClass
Extracted source (around line #5):
2: Your basic information
3:
2007 Dec 06
2
passing parameters through link_to
Is it possible to pass parameters through link_to that will be used by
the controller that link_to directs to? Specifically I have this
code:
<% for user in @users -%>
<%= link_to user.screen_name, {:action => "index", :controller =>
"users", :user_id => user.id } %>
<% end %>
Is it possible to use the parameter at the end of link_to(:user_id
2006 Apr 26
6
get foreign key table data
Hi
I?m trying to bring across all related data.
My table clients has a foreign key field that stores the id of an
organization
How can I grab the details of the organization to use in the clients
show.rhtml file?
Thanks
Scott
--
Posted via http://www.ruby-forum.com/.
2011 Jan 24
11
Can't get login to work
Hi, could anybody help me try to get a login function working, I have
created a database for users called user1, I have the login screen set
up but when i hit login with a correct username and password, nothing
happens
I am expecting the lgin button to direct the user to the main page and
show the user as logged on, but nothing happens! Thanks!
Controller
class User1Controller <
2009 Apr 06
9
setup method in functional tests and instance variables
I have the following in my functional test file.
class UserControllerTest < ActionController::TestCase
fixtures :users
def setup
@controller = UserController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@invalid_user = user(:invalid_user)
@valid_user = users(:valid_user)
end
def test_login_success
2008 Jul 07
3
How to get a users screen name into a hidden field in a PostsController action?
Instead of the user entering a name, I want to pass their screen name
along with supplied :title and :content fields. here is what I''ve
got..
f.hidden_field :author, user.screen_name
here is the create method from Posts controller:
def create
@title = "Gravity"
@user = User.find(params[:id]) # this does not work, and I don''t
know why
if request.post?
2009 Sep 25
12
uniqueness validation perplexity
I want to write a validate routine to check to enforce that a position
must be unique in a category. (In another category, it doesn''t have
to and shouldn''t need to be unique.) I write this code which works
happily for new items:
def position_in_category_not_unique
@items = Item.find( :all, :conditions => [ "category_id = ? AND
position = ?", category_id,
2006 Aug 16
6
Create several models at once and validating
I have two models User and Team. Also I have a register form where the
new
user fill in her data and choose a name for a Team.
Well, in the user model there are several validations which work fine,
but
team model also have a validation for a uniqueness name that doesn''t
fire up
when she gives an existent team''s name.
This is the flow it follows:
/user/new -> it shows a
2011 Jul 15
3
Ruby variable that embeds html tags
This seems very simple, but I can''t quite get it. Probably because I''m
just starting out with RoR.
My view has a slew of labels and text fields; many are "required":
<%= f.text_field :screen_name %> <span class="required_field">Required
field</span>
(The "required_field" class turns the text red and smaller.) I''d like
to