Question: I'm new in Ruby/Rails, so, my question: what is the perfect way to upload file and save filename in database with rails? Are there any Gem? Or maybe there are good build-in feature?

Answer: 
Just take a look on the links to choose between paperClip & carrierwave :

[Rails 3 paperclip vs carrierwave vs dragonfly vs attachment\_fu](https://stackoverflow.com/questions/7419731/rails-3-paperclip-vs-carrierwave-vs-dragonfly-vs-attachment-fu)

And

<http://bcjordan.github.com/posts/rails-image-uploading-framework-comparison/>
Most people use the [Paperclip Gem](https://github.com/thoughtbot/paperclip).