SQL in rails

Hi all…

please give me an example that use SQL in models to handel data in
the data base. with “sql.execute” or any other possible way…


class Model < ActiveRecord::Base
def raw_sql_query
connection.execute(“select name from #{table_name}”)

The above example will return something like this:
[{:name => “A”}, {:name => “B”}]

thankx Andrew
I’ll try it

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs