How can i solve this problems if i dont't use injection sql command in controller?
More details
See this question:
http://www.stackoverflow.com/questions/4727470/how-to-make-rails-external-database-calls
Basically, the point is that you can define the connection to the other database in database.yml. ActiveRecord::Base will inherit from one by default, but you can use the establish_connection method to connect to the other database that you've configured for a given model.
Then you can use the ActiveRecord API (e.g. find_by_sql) to query the other database.
I think you won't (or at least shouldn't) get around using at least ActiveRecord models and querying them using find_by_sql.
Refer to: http://api.rubyonrails.org/classes/ActiveRecord/Querying.html#method-i-find_by_sql