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: 
Also try [carrierwave](https://github.com/jnicklas/carrierwave), Ryan has a good screencast about this [gem](http://railscasts.com/episodes/253-carrierwave-file-uploads)
Most people use the [Paperclip Gem](https://github.com/thoughtbot/paperclip).