25
votes
4answers
4k views

accepts_nested_attributes_for with find_or_create?

I'm using Rails' accepts_nested_attributes_for method with great success, but how can I have it not create new records if a record already exists? By way of example: Say I've got three models, Team, ...
60
votes
6answers
15k views

Rails 3: “field-with-errors” wrapper changes the page appearance. How to avoid this?

Email field: <label for="job_client_email">Email: </label> <input type="email" name="job[client_email]" id="job_client_email"> looks like this: But, if the email validation ...
3
votes
3answers
5k views

Rails validation over redirect

I'm trying out the beast forum written in rails and will use this as an example of a problem I keep facing. The forum has a topics/show action and view with a form at the bottom to create a new post ...
48
votes
7answers
37k views

How do I validate a date in rails?

I want to be able to validate a date in my model in ruby on rails. However, the day, month and year values are already converted into an incorrect date by the time they reach my model. For example, ...
20
votes
8answers
8k views

Why doesn't Rails' “errors.full_messages” replace attribute and message variables?

Having a strange problem with a rails model I just created. Here are my validations: validates_presence_of :from_name, :message => 'Please provide a from name.' validates_presence_of :from_email ...
41
votes
3answers
13k views

Ruby on Rails Callback, what is difference between :before_save and :before_create?

could you explain me in detail about :before_save and :before_create in RoR callback ? And what to do with rails validation ? Is validation works after :before_save or :before_create ?
44
votes
6answers
11k views

accepts_nested_attributes_for child association validation failing

I'm using accepts_nested_attributes_for in one of my Rails models, and I want to save the children after creating the parent. The form works perfectly, but the validation is failing. For simplicity's ...
66
votes
12answers
30k views

What's the state of the art in email validation for Rails?

What are you using to validate users' email addresses, and why? I had been using validates_email_veracity_of which actually queries the MX servers. But that is full of fail for various reasons, ...
16
votes
2answers
12k views

Smarter paperclip validations

I'm using paperclip in a rails app and have the following three validations in my model validates_attachment_presence :photo validates_attachment_size :photo, ...
15
votes
3answers
28k views

Rails form validation

I have a Rails app that lets a user construct a database query by filling out an extensive form. I wondered the best practice for checking form parameters in Rails. Previously, I have had my results ...
35
votes
4answers
6k views

Where should Rails 3 custom validators be stored?

I've seen docs/websites show that custom validators should go in a /lib or /lib/validators directory of a project. I've found (by reading an answer to another post) that they only seem to work in ...
12
votes
6answers
4k views

Validates acceptance always failing

I can't see what I'm missing, but something's obviously not right. I might be being blind, but any thoughts appreciated In model: validates :terms, :acceptance => true, :on => :update Trying ...
3
votes
2answers
7k views

Rails Nested Attributes Association Validation Failing

I have nested attributes for a Rails model and the associations validations are failing for some reason. I am not useing accepts_nested_attributes_for, but I am doing something very similar. class ...
17
votes
3answers
10k views

rails built in datetime validation

Does rails do any validation for datetime? I found a plugin http://github.com/adzap/validates_timeliness/tree/master, but it seems like something that should come in out of the box.
19
votes
4answers
6k views

Spork: how to refresh validations and other code?

I've been using spork all day, and most of the time it is a really great. However, I am often running into a few problems where I need to restart Spork in order for my tests to pass... and now I'm ...

1 2 3 4 5 11
15 30 50 per page