I am creating a Blog using RoR with a sign-in feature and I want to limit each article submission to say 1,000 characters and anyone’s responding comments to 350 max. How would I implement or even start this?
Ideally the char count will count down when a char is added and change color when in the minus numbers (like Twitter).
or,
The article or comment throws up a flash notification if the user goes over the limit.
Am thinking that I can actually limit the char count adding the following in the model:
validates_length_of :article, :maximum => 800
validates_length_of :comment, :maximum => 400
Its the method of showing the user the remaining char count as they type, but on the client side for now? Can RoR do this?
The validations you are asking, are very simple.
I would suggest you to implement them at the client side in the browser using javascript, jquery or any other js framework of your choice.
If you do the validations at the server side, in Rails, you will still need to bind the textfield element with some javascript events associated with it.
So, don’t do such validations at server-side(Rails here), if you want such a high level of UI.